Raise σ to make the accel trace jitter, raise drift to make the gyro trace wander off. Watch the fused estimate stay near truth.

Complementary Filter

What you are looking at

Faint trace
The true tilt.
Red trace
The accelerometer’s noisy estimate.
Gyro trace
The smooth estimate that can drift.
Fused trace
The combination of the two sensor estimates.

Try this

  1. Set α near 0.99 and raise gyro drift to see the fused tilt follow the drift.
  2. Move α toward 0.50 to see more accelerometer noise come through.

Key idea

The gyro handles fast changes smoothly. The accelerometer provides a long-term reference to gravity.

Copy link