46 Kalman Filters for Sensor Fusion
More
Depth: Practitioner
Progress saves as you read. Mark sections complete as you go; your progress appears in the sidebar.
46.1 Start With the Story
This section: Start With the Story — Imagine a cart using a wheel count and a motion sensor to estimate speed.
Keep the Estimate and Its Doubt Together
Imagine a cart using a wheel count and a motion sensor to estimate speed. One source drifts. The other shakes. A smooth line may still be wrong if the system hides how sure it is.
Start with a state the team can name, such as speed now. Predict what the next value should be. Compare that prediction with the next reading. Give less weight to a source when its expected error is larger.
Record the estimate, time, expected error, new reading, gap, correction, and final doubt for each step. Then freeze one sensor, add a sudden jump, lose a reading, and change the rate. The output should show doubt before a person trusts it.
A simple filter depends on its model and error beliefs. It is not a truth machine. Practitioner works through tuning and a small update. Under the Hood explains gates, model limits, and failure modes that can make a calm line unsafe.
Check the model guess, measured gap, doubt, and correction before you trust the next state.
46.2 Kalman Filters Maintain Belief
This section: Kalman Filters Maintain Belief — A Kalman filter is a state estimator for systems that can be described with a model, measurements, and uncertainty.
A Kalman filter is a state estimator for systems that can be described with a model, measurements, and uncertainty. The filter keeps two things together: a best estimate of the state and a covariance that describes the uncertainty in that estimate. It predicts the next state from the model, then corrects that prediction when a measurement arrives.
For IoT sensor fusion, the important idea is not that the output is smooth. The important idea is that every fused estimate carries its uncertainty and update evidence. A temperature estimate, location estimate, or velocity estimate should record the state vector, time step, process noise, measurement noise, innovation, Kalman gain, accepted/rejected measurements, and degraded-mode status.
If the model is linear and the noise assumptions are reasonable, a Kalman filter gives a principled way to balance prediction and measurement. If those assumptions are weak, the filter still needs validation gates and review evidence.
The state vector is the contract between the physics and the software. A simple tracking filter might estimate position and velocity; a building filter might estimate temperature plus a slowly changing sensor bias. The transition model says how that state should move between samples. The observation model says how a sensor reading relates to the hidden state. Those two models are separate on purpose: a sensor may measure only one part of the state, and the filter still uses the model to carry the unmeasured parts forward.
Noise terms make the estimate reviewable instead of magical. Process noise says how much the model can be wrong between updates; measurement noise says how much the sensor can be wrong when it reports. The filter should publish those assumptions with the fused output or at least preserve them in the audit record, because changing Q or R can change whether the same measurement is accepted, rejected, or only partly trusted.
Use Figure 46.1 to follow the filter as an evidence loop rather than treating its equations as an isolated recipe.
Trace Figure 46.1 from the prior estimate and covariance into prediction, then compare the measurement with that prediction to form the innovation. The innovation covariance determines the Kalman gain, which controls the correction and the updated uncertainty carried into the next cycle. Watch the Q and R assumptions alongside the residual: they express process and measurement uncertainty, and a persistent mismatch is diagnostic evidence. This closes the chapter's running loop between physical assumptions, sensor quality, state belief, and reviewable failure checks.
State
The hidden variables being estimated, such as temperature, position, velocity, or bias.
Covariance
The uncertainty attached to the current state estimate and relationships between state dimensions.
Prediction
The model-based step that advances the state and usually increases uncertainty.
Correction
The measurement update that uses innovation and gain to adjust the state and reduce uncertainty.
Overview Knowledge Check
46.3 Tune Prediction vs Measurement
This section: Tune Prediction vs Measurement — In the scalar case, the Kalman gain shows the trust balance directly.
In the scalar case, the Kalman gain shows the trust balance directly. A high gain means the measurement pulls the estimate strongly. A low gain means the model prediction dominates. Process noise Q controls how much uncertainty is added during prediction; measurement noise R controls how much the filter trusts the sensor. Both should be based on observed behavior and retested after sensor, firmware, sampling, or deployment changes.
Worked example: one scalar temperature update previous estimate x: 20.0 deg C previous variance P: 0.50 process noise Q: 0.10 measurement z: 21.2 deg C measurement variance R: 0.40 state model F: 1 measurement model H: 1 predict: x_pred = 20.0 P_pred = P + Q = 0.50 + 0.10 = 0.60 innovation: y = z - x_pred = 21.2 - 20.0 = 1.2 deg C S = P_pred + R = 0.60 + 0.40 = 1.00 Kalman gain: K = P_pred / S = 0.60 / 1.00 = 0.60 update: x_new = x_pred + K * y = 20.0 + 0.60 * 1.2 = 20.72 deg C P_new = (1 - K) * P_pred = 0.40 * 0.60 = 0.24 Interpretation: The estimate moves toward the measurement but does not copy it. The variance drops from 0.60 predicted to 0.24 after the measurement update.
Practitioner Knowledge Check
46.4 Innovation Gating Protects Estimates
This section: Innovation Gating Protects Estimates — The innovation is the difference between what the sensor reports and what the filter predicted the sensor should report.
The innovation is the difference between what the sensor reports and what the filter predicted the sensor should report. Large innovations can be real changes, bad tuning, stale timestamps, miscalibration, sensor faults, or a model that no longer fits the operating mode. Production filters should treat the innovation as evidence, not just a number inside the update equation.
A common scalar gate compares the innovation squared with its expected variance. If the normalized innovation is too large, the system can reject the measurement, downweight it, publish a degraded mode, or trigger a sensor-health review. This connects Kalman filtering to the broader fusion contract: accepted and rejected inputs must be visible.
Covariance is also a design surface, not just a matrix in the code. If a sensor becomes stale, the predicted covariance should usually grow because the state is less certain. If two measurements share a calibration source, the filter should not treat them as fully independent evidence. If an innovation gate rejects several readings in a row, the output record should show whether the system is holding the model prediction, using a fallback sensor, or stopping an action because observability is weak.
Residual review closes the loop. Engineers can plot innovations over time and compare them with the assumed noise model. Persistent positive residuals can reveal bias; residuals that spike after firmware or enclosure changes can reveal a timing or calibration problem; residuals that are always smaller than expected can indicate overestimated noise. That review evidence is what keeps Q, R, gates, and covariance from becoming untested constants.
Worked example: normalized innovation gate predicted state: 12.0 m predicted variance P: 0.64 measurement z: 14.0 m measurement variance R: 0.36 innovation: y = z - prediction = 14.0 - 12.0 = 2.0 m innovation variance: S = P + R = 0.64 + 0.36 = 1.00 normalized innovation squared: NIS = y^2 / S = 4.0 / 1.00 = 4.0 decision example: If the configured one-dimensional gate is 3.84, this measurement is outside the gate. Quarantine it, publish the predicted state with degraded evidence, and record the rejection reason for review.
Innovation
Measurement minus predicted measurement; the first signal that model and sensor disagree.
Gate
A plausibility rule that prevents a single suspect reading from corrupting the fused state.
Retest
Required after tuning changes, sensor replacement, firmware updates, or changed operating modes.
Fallback
Degraded-state publishing, last-good hold, alternate sensor use, or actuation stop when observability is weak.
Under-the-Hood Knowledge Check
46.5 Summary
This section: Summary — Kalman filters combine a predictive model with measurements while carrying uncertainty through every step.
Kalman filters combine a predictive model with measurements while carrying uncertainty through every step. The prediction step advances the state and increases uncertainty with process noise. The update step compares the measurement with the prediction, computes an innovation and gain, adjusts the state, and reduces uncertainty when the measurement is accepted. Practical IoT use requires explicit Q/R tuning evidence, timestamp alignment, calibration checks, innovation gates, rejected-input records, degraded modes, and retest triggers.
A Kalman filter is trustworthy only when the fused state, covariance, tuning assumptions, innovation evidence, accepted or rejected measurements, and fallback behavior are visible together.
46.6 See Also
This section: See Also
Fusion Architectures
Place Kalman state estimates within centralised, hierarchical, or distributed fusion patterns.
Fusion Best Practices
Use calibration, time alignment, gates, and degraded modes around the estimator.
Particle Filters
Compare Kalman assumptions with sampling-based filters for nonlinear or non-Gaussian states.
Complementary IMU Fusion
Contrast covariance-based correction with lightweight embedded orientation fusion.
Kalman filter narrated tour
Narrated audio tour. The full transcript is below.
Play the tour to open the simulator. Pause, replay a beat, or read the full transcript below.
Some beats explain situations this teaching model cannot show; those beats keep the existing frame and provide captions only.
Full transcript — Kalman filter (8 beats)
B1 — Building estimate
You are the engineer responsible for a building’s temperature estimate from connected sensors. Your team needs that temperature and its uncertainty to decide whether to adjust the heating. How should a model prediction and a noisy sensor reading share influence?
Model caption: Cart-position illustration of the same estimation idea. Your building task: estimate temperature and retain its uncertainty.
B2 — Predict and correct
A Kalman filter estimates a state, such as temperature, and carries uncertainty with it. It first predicts from a model, then corrects that prediction when a measurement arrives. For a single temperature value, variance describes the uncertainty attached to the estimate. The Kalman gain sets how strongly the reading changes the prediction.
Model caption: Cart illustration: predict using the model, then correct using a reading. Variance represents uncertainty; gain determines the reading's influence.
B3 — Missing measurement
Process noise represents uncertainty added because the model can be wrong between updates. Measurement noise represents uncertainty assigned to the sensor reading. A higher gain gives the measurement more influence; a lower gain gives the prediction more influence. Without a reading, the teaching model keeps its predicted estimate and predicted uncertainty, with no measurement correction.
Model caption: Process noise adds model uncertainty; measurement noise expresses sensor uncertainty. Gain balances their influence. When the reading is missing, predicted estimate and predicted variance are kept.
B4 — Temperature prediction
Take the chapter’s temperature example. The previous estimate is twenty degrees Celsius, with variance zero point five zero. The model keeps the temperature prediction at twenty. Adding process noise of zero point one zero raises the predicted variance to zero point six zero. Prediction has increased uncertainty before using the reading.
Model caption: Temperature example: previous estimate = 20.0 °C; previous variance = 0.50; process noise = 0.10. Predicted estimate = 20.0 °C; predicted variance = 0.50 + 0.10 = 0.60.
B5 — Innovation
The sensor reports twenty one point two degrees Celsius, with measurement variance zero point four zero. Subtracting the predicted twenty from that reading gives a gap of one point two degrees. That gap is called the innovation: measurement minus prediction.
Model caption: Measurement = 21.2 °C; measurement variance = 0.40. Innovation = measurement − prediction = 21.2 − 20.0 = 1.2 °C.
B6 — Gain and correction
Add the predicted variance, zero point six zero, to the measurement variance, zero point four zero, giving one. Divide zero point six zero by one: the gain is zero point six zero. Add that fraction of the gap to twenty, giving twenty point seven two degrees Celsius.
Model caption: Combined variance = 0.60 + 0.40 = 1.00. Gain = 0.60 / 1.00 = 0.60. Updated temperature = 20.0 + 0.60 × 1.2 = 20.72 °C.
B7 — Partial correction
The misconception is that accepting a reading means replacing the prediction with it. The gain applies only part of the gap, so the result is twenty point seven two, while the reading was twenty one point two. Updated variance is one minus the gain, times predicted variance: zero point two four.
Model caption: Cart illustration: accepting a reading need not copy it. Temperature example: result 20.72 °C versus reading 21.2 °C; updated variance = (1 − 0.60) × 0.60 = 0.24.
B8 — Estimate and uncertainty
For your building estimate, carry the estimate and its doubt together.
Model caption: Carry the estimate and its doubt together.
46.7 Constant-Velocity and Navigation Evidence
This section: Constant-Velocity and Navigation Evidence — Inspect Figure 46.2 to make the hidden state, observed quantity, and uncertainty path explicit before tuning a filter.
Inspect Figure 46.2 to make the hidden state, observed quantity, and uncertainty path explicit before tuning a filter.
Read Figure 46.2 from PREDICT, where the F matrix couples position and velocity, to OBSERVE, where H = [1 0] measures position only. PREDICTED COVARIANCE and CORRECTED STATE show that the filter carries uncertainty as well as a state value.
Next, inspect Figure 46.3 to turn the algebra into a visible uncertainty cycle and compare what prediction and measurement each contribute.
Follow PRIOR to PROPAGATE in Figure 46.3 to see covariance widen, then compare MEASURE with POSTERIOR to see the accepted fix reduce uncertainty. The GAIN panel names the model-versus-sensor balance rather than hiding it behind a smoothed trace.
Finally, inspect Figure 46.4 for a state-design failure that repeated position fixes cannot solve by themselves.
Compare the constant true heading with the gyro-integrated path in Figure 46.4. The growing curve is not random position noise; it is the effect of a gyro bias that the state does not represent. Intermittent GPS fixes pull each position snapshot back toward the observed track, yet the next segment bends again because the same hidden bias still drives heading. Read the state-design warning last. Adding gyro bias as an estimated state gives later measurements a way to correct the cause. Repeated position fixes otherwise repair only the visible symptom and can make a weak model appear briefly healthy.
Find help
3 reviewed answers.
Where should I start in a module?
Open the module page from the sidebar to see its chapters in order. Use the module map to return to a topic you need.
Modules and pathsReviewed
What can I try when a project does not work?
Check the symptom, then work through the diagnostic steps. Keep the error message and the smallest example that reproduces it.
When you are stuckReviewed
How do interactive examples work?
Use the interactive guide to check how examples and simulations work before changing your project.
Interactive examples guideReviewed
