State estimation
A robot never measures its state directly; it infers orientation, velocity and position from noisy, biased sensors. This page covers IMU models, complementary and Mahony filters, the Kalman filter, leg odometry and LiDAR SLAM, and what Strido actually publishes.
In Strido
The XIAO ESP32-S3 reads an LSM6DSOX IMU and runs a Mahony filter in its firmware/strido_esp32s3/src/main.cpp, period kControlPeriodUs = 5000 in board_config.h). ros2/strido_control/strido_control/mcu_bridge.py republishes it as /imu/data; gait_node.py publishes /odom by dead reckoning; an RPLIDAR C1 publishes /scan (see docs/software.md and Sensors).
IMU measurement models
An inertial measurement unit contains a 3-axis gyroscope (angular velocity) and a 3-axis accelerometer (specific force). Both are expressed in the sensor's body frame
Gyroscope.
Accelerometer. It measures acceleration minus gravity, rotated into the body:
where
The two sensors are complementary: gyro is smooth but drifts; accelerometer is noisy but drift-free.
The complementary filter
For one tilt angle
In the frequency domain this is a high-pass on the gyro plus a low-pass on the accelerometer with the same cut-off; the crossover time constant is
Worked example. At Strido's
The Mahony filter (what the firmware runs)
Mahony's filter is a complementary filter on the rotation group, using a quaternion
- Predict the gravity ("up") direction from the current estimate:
. - Normalise the accelerometer:
. - The error is the rotation needed to align them:
- Correct the gyro with proportional and integral feedback (the integral term converges to minus the gyro bias, cancelling it):
- Integrate the quaternion kinematics
and renormalise:
In the firmware, Adafruit_Mahony is started at updateIMU (gyro and accelerometer only, no magnetometer). Before filtering, board axes are remapped to the base frame because the IMU is mounted with its
The sensor is configured for
The Kalman filter
The Kalman filter is the optimal estimator for linear systems with Gaussian noise. State
Predict (propagate the model; uncertainty grows):
Update (fuse a measurement; uncertainty shrinks):
The gain
Leg odometry
If a stance foot does not slip, its world position is fixed, so the body velocity follows from the leg's joint velocities through forward kinematics (see Kinematics):
averaged over the stance feet and integrated for position. Errors come from slip, contact detection and calibration, so it drifts; state-of-the-art quadrupeds fuse it with the IMU in an EKF.
Strido's hobby servos have no position feedback: /joint_states reports the commanded angles after clamping, not measured ones. True leg odometry is therefore not available, and gait_node.py does something simpler: it integrates the commanded body velocity,
with no slip model. If the robot actually achieves 80 % of a /odom overestimates distance by
LiDAR scan matching and SLAM
A 2D LiDAR returns ranges
where /odom ("a seed for SLAM").
What Strido publishes
| Topic | Contents | Source |
|---|---|---|
/imu/data (sensor_msgs/Imu, frame imu_link, axes aligned with base_link) | orientation quaternion from the Mahony filter, angular velocity in | mcu_bridge.py, state stream at kStatePeriodMs = 10) |
/odom + TF odom base_link (nav_msgs/Odometry) | dead reckoning of the commanded velocity | gait_node.py only |
/scan (sensor_msgs/LaserScan, lidar_link) | RPLIDAR C1 ranges at | sllidar_ros2 |
The learned policy uses only /imu/data: the gyro and the gravity direction derived from the quaternion (see Reinforcement learning).
Check yourself
Why can an accelerometer give roll and pitch but not yaw?
Answer
It measures the gravity direction in the body frame; rotating about the vertical axis does not change that direction.
With
, what gives a complementary-filter time constant of ? Answer
, so . What does the integral gain
in the Mahony filter estimate, and what happens with ? Answer
The gyro bias. With
a constant bias leaves a small steady roll/pitch offset of about and uncorrected yaw drift. In the Kalman update, what happens to
as ? Answer
: the measurement is ignored and the estimate follows the prediction. Why can't Strido do classic leg odometry?
Answer
Its servos give no joint-position feedback, so the actual
and are unknown; only commands are available.
Further reading
- R. Mahony, T. Hamel and J.-M. Pflimlin, "Nonlinear Complementary Filters on the Special Orthogonal Group", IEEE Transactions on Automatic Control, 2008.
- S. Thrun, W. Burgard and D. Fox, Probabilistic Robotics, MIT Press, 2005.
- J. Solà, "Quaternion kinematics for the error-state Kalman filter", arXiv:1711.02508, 2017.
- M. Bloesch et al., "State Estimation for Legged Robots — Consistent Fusion of Leg Kinematics and IMU", Robotics: Science and Systems, 2012.
- W. Hess, D. Kohler, H. Rapp and D. Andor, "Real-Time Loop Closure in 2D LIDAR SLAM" (Cartographer), IEEE ICRA, 2016.