Troubleshooting · Sensors
IMU orientation drifts
A gyroscope integrates its own bias. Measure the drift rate, decide whether it is bias, temperature or the filter, and give the filter a reference that does not drift.
1. Symptoms
- Yaw changes slowly with the robot stationary.
- Roll and pitch settle at a wrong value or slide.
- The drift rate changes as the IMU warms up.
2. Possible causes
- Gyro bias: a constant rate offset integrates into a linearly growing angle.
- Temperature: bias changes while warming up.
- No absolute reference for yaw: accelerometer fixes roll and pitch (gravity) but not yaw; a magnetometer, GNSS heading or vision is needed.
- Magnetometer disturbance from motor currents or steel (a corrupted yaw reference).
- Wrong units or axes into the filter (the
Imumessage uses m/s² and rad/s). - Vibration biasing the accelerometer.
3. Measurements to collect
- Gyro output with the robot still for several minutes (mean = bias, standard deviation = noise).
- Drift rate in degrees per minute, before and after warm-up.
- Magnetometer field magnitude and direction with the motors off and on.
- The IMU covariance values and the filter’s inputs.
4. Diagnostic commands
Commands are not executed by the site’s automated tests (they need a ROS 2 Jazzy installation or the robot).
ros2 topic echo /imu/data --field angular_velocity --once
ros2 bag record /imu/data /imu/mag
# analyse offline: mean and std of angular_velocity while still5. Step-by-step investigation
- Record 5 minutes with the robot still and compute the mean of each gyro axis. A non-zero mean is the bias; its integral is the drift.
- Repeat after warm-up to see temperature dependence.
- Check units and axes: the message uses rad/s and m/s²; the frame follows REP 103 (x forward, y left, z up).
- Check what stops yaw drift: is a magnetometer, GNSS heading or visual/LiDAR correction fused?
- Check the magnetometer with motors on and off; a change means disturbance.
- Check covariance: an all-zero covariance means unknown, and a first element of −1 means no estimate; the filter must not treat these as perfect.
6. Corrective actions
- Subtract the measured bias at start-up (stationary calibration) and let the filter estimate it online.
- Allow warm-up, or compensate temperature if the datasheet gives a coefficient.
- Add a yaw reference: magnetometer after calibration and away from currents, dual-antenna GNSS, or visual/LiDAR odometry.
- Mount the IMU rigidly and away from motors; use vibration isolation if needed.
- Correct units, frames and covariances.
7. Validation after the fix
- Stationary drift rate measured and below the requirement over the mission time.
- Yaw error after a loop or a long run is within the requirement with the reference sensors enabled.
- Results repeat after a cold start.
References
- sensor_msgs definitions (Jazzy): ros2/common_interfaces, read 2026-11-05.
Imu: m/s² and rad/s; zero covariance means unknown; first element −1 means no estimate. - REP 103: rep-0103.rst.
- Related guide: inertial and positioning sensors guide.