TactivergeLite

Lite / Independent Engineering Research / Week 15

The predict–update cycle

Drive a metre: your uncertainty grows. See a landmark: it shrinks. Repeat forever. That rhythm is the whole idea of a filter.

About 45 min · 3 goals · Checked by automated tests · Full interactive version

Why should I care?

This is the loop running inside every rover, drone and phone that knows where it is. Once you can step it by hand, the Kalman filter stops being a formula and becomes a story: predict, get surprised, correct by the right amount.

Predict

During a dust storm the camera fix is unavailable for 5 steps in a row. What happens to the filter's variance P?

  1. It grows by Q every step
  2. It stays constant
  3. It shrinks
  4. It resets to zero
Guess first, then reveal

With no update, only predict runs: P ← P + Q each step. The band widens steadily until a fix returns, then snaps narrower.

Discover

Step predict → update ten times in clear skies and watch the band settle to a steady width. Reset, switch on dust, and step again: note how wide the band gets during the gaps. Check after each update that the green truth line stays inside the ±2σ band most of the time.

What the interactive shows (text version)

The Kalman stepper plots truth, landmark fixes and the estimate with a ±2σ band over 20 steps. Each button press updates a text readout with the estimate, σ, truth, error and gain.

You can also open the interactive on the full site when you have a faster connection.

Watch (optional)

Watch for: Listen for the two reasons given for a filter: noisy measurements, and quantities you cannot measure at all.

Builds intuition for estimating what you can't measure directly when your sensors are noisy.

“Why Use Kalman Filters? | Understanding Kalman Filters, Part 1” by MATLAB (opens YouTube; streaming video uses a lot of data)

The video is optional. Everything you need is in this lesson's text.

Understand

Predict

Push the estimate through the model: x⁻ = x + u (here, the commanded move) and P⁻ = P + Q. Q is the variance the model adds each step: wheel slip, gusts, anything unmodelled. Prediction always increases uncertainty.

Update

When a measurement z with variance R arrives, compute the innovation z − x⁻, the gain K = P⁻/(P⁻ + R), then x = x⁻ + K(z − x⁻) and P = (1 − K)P⁻. This is the conjugate normal update from week 13 with the prediction as prior.

Checking a filter honestly

In simulation you know the truth, so measure RMSE of x − x_true. Also check consistency: about 95% of errors should fall within ±2√P. If the truth often leaves the band, the filter is overconfident (Q or R too small); if it never comes close to the edge, it is too cautious.

Explain it another way

Intuitive

You are walking in fog. Each step you are a little less sure where you are. When a lamppost appears you correct, more if you trust your eyes, less if the fog is thick.

Technical

With constant Q and R the variance converges to a steady state: prior variance P⁻∞ = (Q + √(Q² + 4QR))/2, giving a constant steady-state gain. Many embedded filters just use that constant gain.

Mathematical

x = 0, P = 1, u = 1, Q = 0.25: x⁻ = 1, P⁻ = 1.25. z = 1.6, R = 0.5: K = 1.25/1.75 ≈ 0.714, x = 1 + 0.714 × 0.6 ≈ 1.43, P = 0.286 × 1.25 ≈ 0.357.

Applied

BUILD 006's rover uses exactly this cycle: odometry predicts, a landmark photo updates. Its Level 2 numbers, odometry σ = 1 m meeting a camera σ = 0.5 m, give K = 0.8 and a fused σ ≈ 0.45 m.

Worked example 1

x = 0, P = 1 m². Drive u = 1 m with Q = 0.25 m². Fix z = 1.6 m with R = 0.5 m². Predict and update.

x⁻ = 1, P⁻ = 1.25. K ≈ 0.714. x ≈ 1.43 m, P ≈ 0.357 m² (σ ≈ 0.60 m).

Common mix-ups

Practice

Practice, not a test. Answers are checked on our server; a wrong answer gets a hint and another try. Nothing is saved.

m

m²

Practice 3. In simulation, the true position leaves the filter's ±2σ band on 40% of steps. The most likely problem is…

Apply it

In the stepper, run 20 steps in dusty conditions with Q = 0.2 and R = 1. Record the error and √P at each step and compute the fraction of steps where |error| < 2√P. Repeat with Q set ten times too small (in your head, the filter's Q, not the truth's). What changes?

Reflect

What would you tell a teammate who wants to set R = 0 'because the camera is really good'?

Write your answer on paper or in your own notes. Lite never stores what you write.

← Aerospace sensing: IMUs, star trackers, sun sensors and radioInverse-variance weighting →