subscribe_imu
Signature:
BoosterRobot.subscribe_imu(
callback: Callable[[IMUState], None],
*,
imu_id: str = "",
queue_size: int = 0,
overflow: OverflowPolicy = "drop_oldest",
) -> SensorSubscription
Description:
Subscribe to IMU data updates. When data arrives, the callback receives an IMUState object.
Parameters:
Parameter | Type | Default | Description |
|---|---|---|---|
|
| Required | IMU callback function. |
|
|
| IMU ID; leave empty to use the default IMU. |
|
|
| Pending callback queue size; |
|
|
| Policy when the queue is full; see "Tasks and Subscriptions / OverflowPolicy". |
Returns:
SensorSubscription, see "Tasks and Subscriptions / SensorSubscription"
Raises:
None.
Example:
import time
from boosteros.robots.booster import BoosterRobot
from boosteros.types import IMUState
robot = BoosterRobot()
def on_imu(data: IMUState) -> None:
print(data.timestamp, data.rpy)
# Example output: 1781085634.9679394 [1.11528370e-05 4.49275300e-02 -1.56997216e+00]
sub = robot.subscribe_imu(on_imu)
try:
time.sleep(2.0)
finally:
sub.unsubscribe()