libstp.robot.heading_reference

Classes

HeadingReferenceService

Stores an absolute IMU heading reference and computes turns relative to it.

Module Contents

class libstp.robot.heading_reference.HeadingReferenceService(robot: libstp.robot.api.GenericRobot)

Bases: libstp.robot.service.RobotService

Stores an absolute IMU heading reference and computes turns relative to it.

Use robot.get_service(HeadingReferenceService) to access.

mark() None

Capture the current absolute IMU heading as the reference.

property reference_deg: float | None

The stored reference in degrees, or None if not set.

compute_turn(target_deg: float) float

Compute the signed relative turn angle to reach target_deg from reference.

Parameters:

target_deg – Desired heading in degrees relative to the reference.

Returns:

Signed angle in degrees (positive = CCW / left, negative = CW / right). Normalized to [-180, 180] for the shortest path.

Raises:

RuntimeError – If no reference has been marked yet.