Analytics & ML · Study deck
Complementary Filters: Tuning and Validity
One alpha value cannot fit every update rate and motion state.
Data Dora is your guide for this deck.

After studying this chapter
Learning objectives
You will be able to:
- Explain: The same evidence rule still applies: magnetometers can be corrupted by nearby metal or electronics, and a 9-DOF heading should be labeled degraded when magnetic calibration or field consistency fails.
- Explain: A advances the old state through the physical model, B maps a measured or commanded input into that state, and H selects the combination the sensor can observe.
- Explain: If process covariance Q is too small, the filter becomes overconfident in an imperfect motion/bias model and responds sluggishly to real change.
- Add validity gates for motion, saturation, and bad samples.
Major section
Kalman state-space bridge
The complementary filter uses a fixed blend.
- A Kalman filter makes the same predict-and-correct story explicit as a state model with uncertainty.
- A advances the old state through the physical model, B maps a measured or commanded input into that state, and H selects the combination the sensor can observe.
- The accelerometer angle then enters correction through H and measurement uncertainty R; increasing R during vibration gives that angle less influence.
Major section
Kalman state-space bridge (continued)
If accelerometer variance R rises during vibration, the residual variance grows and the gain normally gives that angle less influence.
- If process covariance Q is too small, the filter becomes overconfident in an imperfect motion/bias model and responds sluggishly to real change.
- The result is a roll or pitch estimate with covariance, not just a smoothed number.
- Calibrated magnetometer values are rotated by roll and pitch into the horizontal plane before atan2 produces yaw.
Major section
Validity Gates Beat Formula
The formula is simple, but production IMU fusion is mostly about knowing when the assumptions are valid.
- The accelerometer should correct roll and pitch only when gravity dominates the measurement.
- Gyroscope integration should be trusted only when bias, saturation, timestamp, and axis calibration are under control.
- Quaternions avoid Euler singularities and support full 3D attitude composition.
Major section
Validity Gates Beat Formula (continued)
Attitude gradually walks away during stationary tests.
- The output should expose those checks instead of publishing a single attitude value with no evidence.
- Madgwick-style filters use a correction gain, often called beta, to pull the quaternion estimate toward accelerometer and magnetometer references.
- Heading changes while roll and pitch remain stable.
Major section
Validity Gates Beat Formula (continued)
The same evidence rule still applies: magnetometers can be corrupted by nearby metal or electronics, and a 9-DOF heading should be labeled degraded when magnetic calibration or field consistency fails.
- Gravity GateCheck whether acceleration magnitude and stability are compatible with gravity before applying strong correction.
- Axis ConventionRecord coordinate frame, sign convention, sensor mounting, and unit conversion so roll, pitch, and yaw are reviewable.
- 6-DOF IMU has no absolute yaw reference.
Deck summary
Key takeaways
The complementary filter uses a fixed blend.
- If accelerometer variance R rises during vibration, the residual variance grows and the gain normally gives that angle less influence.
- The formula is simple, but production IMU fusion is mostly about knowing when the assumptions are valid.
- Attitude gradually walks away during stationary tests.
- The same evidence rule still applies: magnetometers can be corrupted by nearby metal or electronics, and a 9-DOF heading should be labeled degraded when magnetic calibration or field consistency fails.
Retrieval practice
Recall check 1 of 2

Data Dora says: answer from memory, then check your reasoning.
Q1Why should a 6-DOF accelerometer-plus-gyroscope filter label yaw as unobservable or drifting?
Show answer
Answer: D 6-DOF IMUs can use gravity for roll and pitch but need another reference for absolute yaw.
Retrieval practice
Recall check 2 of 2

Data Dora says: answer from memory, then check your reasoning.
Q2A robot brakes hard and its accelerometer no longer mainly measures gravity. What should the attitude filter do with that sample?
Show answer
Answer: D Motion can corrupt the gravity cue; the filter should expose coasting and its growing uncertainty.
Print reference
Answers
Answer key.
- D · 6-DOF IMUs can use gravity for roll and pitch but need another reference for absolute yaw.
- D · Motion can corrupt the gravity cue; the filter should expose coasting and its growing uncertainty.