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.

datafusioncomplementary
Data Dora, the module guide, in a scene from this chapter.
iotclass.org

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\mathbf{A}A advances the old state through the physical model, B\mathbf{B}B maps a measured or commanded input into that state, and H\mathbf{H}H selects the combination the sensor can observe.
  • Explain: If process covariance QQQ 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.
iotclass.org

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\mathbf{A}A advances the old state through the physical model, B\mathbf{B}B maps a measured or commanded input into that state, and H\mathbf{H}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.

Key terms

Calibrated magnetometer values
Calibrated magnetometer values are rotated by roll and pitch into the horizontal plane before atan2 produces yaw.
Roll and pitch keep Kalman prediction and correction explicit, while yaw uses those tilt estimates to rotate calibrated magnetic evidence into the horizontal plane.
Roll and pitch keep Kalman prediction and correction explicit, while yaw uses those tilt estimates to rotate calibrated magnetic evidence into the horizontal plane.
iotclass.org

Major section

Kalman state-space bridge (continued)

If accelerometer variance RRR rises during vibration, the residual variance grows and the gain normally gives that angle less influence.

  • If process covariance QQQ 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.
iotclass.org

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.
Twelve seconds on a delivery robot: vibration and braking both push the accelerometer outside its gate, and the derived angle turns confidently wrong.
Twelve seconds on a delivery robot: vibration and braking both push the accelerometer outside its gate, and the derived angle turns confidently wrong.
iotclass.org

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.
iotclass.org

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.
iotclass.org

Deck summary

Key takeaways

The complementary filter uses a fixed blend.

  • If accelerometer variance RRR 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.
iotclass.org

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?

AThe accelerometer directly measures magnetic north and can reset yaw after each update.
BThe gyro automatically removes heading bias whenever its angular rate is integrated.
CYaw is always better constrained than roll and pitch in a six-degree inertial unit.
DGravity can correct roll and pitch, but it does not provide an absolute yaw heading reference.
Show answer

Answer: D 6-DOF IMUs can use gravity for roll and pitch but need another reference for absolute yaw.

iotclass.org

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?

AGate no accelerometer readings, because fresh braking acceleration is the gravity reference.
BReset attitude to zero and conceal the braking interval from downstream users.
CTreat braking acceleration as a permanent new gravity direction for the filter.
DGate correction, predict briefly with the gyro, and label output degraded.
Show answer

Answer: D Motion can corrupt the gravity cue; the filter should expose coasting and its growing uncertainty.

iotclass.org

Print reference

Answers

Answer key.

  1. D · 6-DOF IMUs can use gravity for roll and pitch but need another reference for absolute yaw.
  2. D · Motion can corrupt the gravity cue; the filter should expose coasting and its growing uncertainty.
iotclass.org