heading_task¶
- class heading_task.HeadingTask(imu)¶
Bases:
object
A class to handle reading the heading from an IMU and updating shared variables.
- imu¶
The IMU sensor instance used for reading heading data.
- Type:
object
- S0_init¶
The initialization state value.
- Type:
int
- S1_read¶
The read state value.
- Type:
int
- state¶
The current state value.
- Type:
int
- target_heading¶
The desired target heading value.
- Type:
int
- get_heading(shares)¶
The generator that implements the finite state machine for the Heading task.
State 0 initializes the IMU sensor to heading mode and transitions to state 1. State 1 reads the heading from the IMU, adjusts it within the 0-360° range, and updates the shared variable.
- Parameters:
shares (heading) – A shared variable to store the heading data.
- Yields:
int – The value of the current state within the machine.