IMU Accelerometer + Gyroscope Complementary Filter Calculator
Calculates the fused angle estimate using a complementary filter that combines high-frequency gyroscope integration with low-frequency accelerometer angle measurement. The filter balances gyroscope drift correction against accelerometer noise.
Accelerometer Inputs
Gyroscope Inputs
Filter Parameter
α close to 1 → trust gyroscope more; α close to 0 → trust accelerometer moreFormulas Used
1. Accelerometer Angle
Roll: θ_accel = atan2(ay, az)
Pitch: θ_accel = atan2(−ax, √(ay² + az²))
2. Gyroscope Integration
θ_gyro = θ_prev + ω · Δt
where ω is the gyroscope angular rate (°/s) and Δt is the time step (s).
3. Complementary Filter
θ_fused = α · θ_gyro + (1 − α) · θ_accel
α = filter coefficient (0 ≤ α ≤ 1)
High α → trusts gyroscope (good for fast dynamics, prone to drift)
Low α → trusts accelerometer (good for slow dynamics, noisy for vibration)
4. Equivalent Time Constant & Cutoff Frequency
τ = α · Δt / (1 − α)
fc = 1 / (2π · τ)
The filter acts as a high-pass filter on the gyroscope and a low-pass filter on the accelerometer, with crossover at fc.
Assumptions & References
- The accelerometer measures gravity plus linear acceleration noise; best results when the sensor is quasi-static or slowly moving.
- The gyroscope rate is in degrees per second (°/s); convert from rad/s by multiplying by 180/π if needed.
- Δt should match the actual sensor sampling interval for accurate integration.
- Typical α values: 0.95–0.99 for most IMU applications at 100 Hz sampling.
- The complementary filter does not correct for gyroscope bias drift over long periods; a Kalman or Mahony filter is preferred for that.
- Accelerometer angle assumes gravity dominates; large linear accelerations will corrupt the angle estimate.
- Reference: Mahony et al. (2008), "Nonlinear Complementary Filters on the Special Orthogonal Group"; Madgwick (2010), "An efficient orientation filter for inertial and inertial/magnetic sensor arrays."
- Formula derivation: Euston et al. (2008), "A complementary filter for attitude estimation of a fixed-wing UAV."