Kalman Filter for IMUs
aliases:
- Kalman Filter IMU
- IMU Kalman Filter
- Extended Kalman Filter IMU tags:
- electronics/imu
- signal-processing/filters
Kalman Filter for IMUs
Why use a Kalman filter?
A Kalman filter (KF) estimates a hidden state from a process model and noisy measurements, while tracking estimate uncertainty. For a 6-DoF IMU it can combine gyro-based changes with gravity-based tilt measurements and can explicitly estimate gyro bias.
Unlike a fixed-gain Complementary Filter, a KF uses process covariance and measurement covariance to determine the correction gain. Neither technique fixes a missing physical measurement: yaw is still not absolutely observable from gyro + accelerometer alone.
Minimal 1-axis example: angle and gyro bias
Let the state be:
and assume changes slowly. Using a measured gyro rate and sample interval :
The prediction covariance is:
The accelerometer, when gravity-dominated, supplies a tilt observation:
The measurement update is:
The last line is the numerically stable Joseph-form covariance update.
Practical steps
- Estimate startup gyro bias using stationary calibration.
- Initialize roll/pitch from a stable gravity-based tilt reading.
- Convert raw BMI088 values to consistent units and use accurate timestamps.
- Define reasonable initial covariance , process covariance , and measurement variance .
- At each sample, predict using gyro measurements; when accelerometer tilt is reliable, update.
- During strong vibration/translation, increase or skip that observation, with care.
- Validate the estimated gyro bias, residuals, tilt response, and uncertainty against controlled tests.
KF vs. EKF
The example above is a linear small-scope angle/bias model, useful for learning and for mostly independent roll/pitch axes. Full 3D orientation is nonlinear; a practical filter often uses a quaternion-based extended Kalman filter (EKF) or error-state Kalman filter to model the relationship between rotation and sensed gravity properly.
Important limitation
An EKF cannot recover absolute heading without an external heading reference. It may track a relative yaw angle, but unobservable yaw bias eventually leads to drift. Add an appropriate magnetometer, visual reference, or other heading measurement if needed.
See also: Complementary Filter · Sensor Fusion and Filtering · 6-DoF IMU · BMI088 - Hardware Connection