hub.imu

Motion sensor: which way the hub is tilted and turned.

pitch, roll and yaw are angles in degrees, from -180 to 180:

  • pitch — nose up / nose down,

  • roll — tilting left / right,

  • yaw — turning around, like a compass.

Wait until calibrated is True before trusting the values. On some hubs yaw slowly drifts over time; call reset() to set it back to 0.

Attributes

acceleration

How hard the hub is being pushed (including gravity), in milli-g.

calibrated

True once the sensor is ready and its readings can be trusted.

gyro_rate

How fast the hub is spinning around each direction, in degrees per second.

pitch

Nose up (+) or down (-), in degrees.

pitch_accel

pitch measured only from gravity. Jumpy, but never drifts. Degrees.

pitch_gyro

pitch measured only from rotation. Smooth, but drifts over time. Degrees.

roll

Tilt to the side, in degrees.

roll_accel

roll measured only from gravity. Jumpy, but never drifts. Degrees.

roll_gyro

roll measured only from rotation. Smooth, but drifts over time. Degrees.

yaw

Which way the hub is facing, in degrees. Use reset() to set the current direction as 0.

yaw_gyro

yaw measured only from rotation. Smooth, but drifts over time. Degrees.

Functions

reset() → None

Set the current direction as yaw = 0.

save_calibration() → bool

Remember the current calibration, so it survives a restart.

start_calibration() → bool

Start calibrating the sensor more precisely.

Module Contents

hub.imu.reset() → None[source]

Set the current direction as yaw = 0.

On some hubs this also re-calibrates the sensor — keep the hub still for about 2 seconds afterwards.

hub.imu.save_calibration() → bool[source]

Remember the current calibration, so it survives a restart.

Call it once calibrated is True. Not every hub can store a calibration; on those this does nothing. Returns True on success.

hub.imu.start_calibration() → bool[source]

Start calibrating the sensor more precisely.

Move the hub in a figure-8, then put it down flat on each side for a few seconds. Returns True if calibration started.

hub.imu.acceleration: _vec3[source]

How hard the hub is being pushed (including gravity), in milli-g.

Lying still and flat, z is about 1000 (that’s gravity).

hub.imu.calibrated: bool[source]

True once the sensor is ready and its readings can be trusted.

Right after start-up (or after reset()) keep the hub still for about 2 seconds until this turns True.

hub.imu.gyro_rate: _vec3[source]

How fast the hub is spinning around each direction, in degrees per second.

hub.imu.pitch: float[source]

Nose up (+) or down (-), in degrees.

hub.imu.pitch_accel: float[source]

pitch measured only from gravity. Jumpy, but never drifts. Degrees.

Type:

Advanced

hub.imu.pitch_gyro: float[source]

pitch measured only from rotation. Smooth, but drifts over time. Degrees.

Type:

Advanced

hub.imu.roll: float[source]

Tilt to the side, in degrees.

hub.imu.roll_accel: float[source]

roll measured only from gravity. Jumpy, but never drifts. Degrees.

Type:

Advanced

hub.imu.roll_gyro: float[source]

roll measured only from rotation. Smooth, but drifts over time. Degrees.

Type:

Advanced

hub.imu.yaw: float[source]

Which way the hub is facing, in degrees. Use reset() to set the current direction as 0.

hub.imu.yaw_gyro: float[source]

yaw measured only from rotation. Smooth, but drifts over time. Degrees.

Type:

Advanced