Appearance
Complementary Filter
Problem Statement
Low-cost IMU attitude estimation suffers from gyroscope drift and accelerometer noise. The complementary filter combines high-frequency gyroscope integration with low-frequency gravity alignment to produce stable orientation estimates for downstream control.
Model and Formulation
Let \omega_m be measured angular rate and a_m the measured acceleration. The roll/pitch estimate is propagated by integrating rates, then corrected with an accelerometer-derived attitude:
$$ \theta_k = \alpha \left(\theta_{k-1} + \omega_{m,k}\Delta t\right) + (1-\alpha)\theta_{acc,k} $$
where \alpha \in (0, 1) defines the crossover between gyro and accelerometer trust.
Algorithm Procedure
- Integrate gyroscope rates to obtain predicted orientation.
- Compute gravity-consistent roll and pitch from accelerometer measurements.
- Blend the two estimates using the complementary gain
\alpha. - Output attitude estimate to attitude and position controllers.
Tuning Guidance
\alphanear0.98works well when IMU rates are high (>= 100 Hz).- Increase accelerometer weighting when gyro bias grows over long flights.
- Reduce accelerometer weighting in aggressive maneuvers where linear acceleration contaminates gravity direction.
Failure Modes and Diagnostics
- Sustained acceleration can be misinterpreted as tilt, causing attitude bias.
- Poor gyro bias handling leads to slow heading/attitude drift.
- Check innovation between gyro-integrated and accelerometer attitude; persistent bias indicates gain mismatch.
Implementation and Execution
bash
python -m uav_sim.simulations.estimation.complementary_filterEvidence

References
- Mahony, Hamel, Pflimlin, Nonlinear Complementary Filters on SO(3), IEEE TAC (2008)
- Sabatini, Quaternion-based complementary filter review (2011)