Embodied AI Glossary中文

Complementary Filter

互补滤波Advanced

A simple filter that blends the gyroscope for short-term accuracy and the accelerometer for long-term stability to estimate attitude angle.

The complementary filter is the simplest and most common method for IMU attitude estimation. The gyroscope measures angular velocity, which integrates into an angle that’s smooth and accurate over short periods, but bias makes error accumulate into drift over time (a low-frequency error); the accelerometer can compute pitch and roll directly from the direction of gravity, which doesn’t drift long-term, but it’s noisy and disturbed by vibration and motion acceleration (a high-frequency error), and yaw needs a magnetometer as an additional reference. The complementary filter high-pass-filters the gyroscope-integrated result and low-pass-filters the accelerometer result, then adds them; a common formula is: angle = α × (previous angle + angular velocity × Δt) + (1 − α) × accelerometer angle, with α set close to 1. It’s extremely cheap to compute, which suits microcontrollers; Mahony and colleagues extended it to full 3D rotation (SO(3)) in IEEE TAC in 2008, giving the commonly used Mahony filter. It needs no noise model, but its weight has to be tuned by hand.

ExampleA self-balancing robot’s main controller reads the IMU once per control cycle and computes the body’s pitch angle with a complementary filter using α = 0.98, feeding it back into the balance controller.

Also called
Mahony Complementary Filter
Related
Inertial Measurement Unit · Kalman Filter · Extended Kalman Filter · Attitude Estimation · Sensor Drift · State Estimation
Sources
Complementary Filter - AHRS 文档 (Chinese)
complementaryFilter - MATLAB Sensor Fusion and Tracking Toolbox

See it in the full glossary →