Lite / Independent Engineering Research / Week 17
Tuning a two-state filter: position and bias
Your wheels lie by 1.5 cm every second, always in the same direction. Could the filter learn that lie and subtract it?
Why should I care?
Real sensors have biases that change slowly. Adding the bias as a state lets the filter estimate and remove it, which is how spacecraft keep gyros honest between star fixes and how the fusion lab's Kalman filter beats the complementary one.
- Augment a state with an unknown sensor bias and write the two-state model.
- Explain how a filter can estimate a state no sensor measures directly.
- Tune Q and R by experiment and diagnose over- and under-confident filters.
Predict
The camera only ever measures position. Can a filter still estimate the odometry bias?
- Yes: the bias shows up as a steady pattern in the innovations over time
- No: you can only estimate what you measure
- Only if the rover stops
- Only with a second camera
Guess first, then reveal
If dead reckoning keeps landing ahead of each camera fix by the same amount per second, that pattern is the bias. The two-state model links bias to position, so the filter infers it.
Discover
In the fusion lab choose the Kalman filter and a clear nonzero odometry bias. Watch the estimated bias converge. Then raise the dropout rate: does the position error during blackouts stay small because the bias has been learned? Compare with the complementary filter on the same seed.
What the interactive shows (text version)
The fusion lab reports position error and, for the Kalman filter, the estimated bias as numbers; the expected behaviour (bias converging, small error during blackouts) is described in the instruction.
Watch (optional)
Watch for: Listen for the idea that the filter estimates the full state, including parts you cannot measure, from a model plus partial measurements.
A university lecture that places the Kalman filter in state-space control: estimating the full state from noisy, partial measurements.
“The Kalman Filter [Control Bootcamp]” by Steve Brunton (opens YouTube; streaming video uses a lot of data)
The video is optional. Everything you need is in this lesson's text.
Understand
Augment the state
State x = [p, b]ᵀ: position and odometry bias. Odometry reports d = Δp_true + b·Δt + noise, so the prediction is p ← p + d − b·Δt and b ← b (a random walk). In matrix form A = [[1, −Δt], [0, 1]], with the odometry reading as input, and the camera measures H = [1, 0].
Observability
A state is observable if its effect eventually appears in the measurements. The bias pushes the position prediction away from the camera fixes at a steady rate, so over several fixes the filter can separate it from random noise. During a long blackout nothing new is learned, but the learned bias keeps being subtracted.
Tuning Q and R
Start R from the sensor's measured noise. Q is harder: it encodes how much the model can be wrong per step (slip, bias wander). Q too small: sluggish, overconfident, truth leaves the ±2σ band. Q too large: jumpy, noisy estimate. Tune on simulated runs with known truth, check consistency, and never tune on the same runs you report.
Explain it another way
Intuitive
If your watch gains a minute every day and you check it against the radio each morning, after a few days you know the gain and can correct for it even on days you miss the radio.
Technical
The pair (A, H) is observable when the matrix [H; HA] has full rank. Here [[1, 0], [1, −Δt]] has rank 2 for Δt > 0, so position and bias are both observable from position fixes.
Mathematical
Process noise for the bias random walk: Q_b = σ_b²Δt. A tiny Q_b says 'the bias barely changes', so the filter averages over many fixes; a larger Q_b lets it track a wandering bias at the cost of noisier estimates.
Applied
Spacecraft attitude filters routinely carry three gyro bias states. After a few star-tracker fixes, gyro-only coasting during an eclipse or manoeuvre is far more accurate than raw integration.
Worked example 1
Δt = 0.1 s. Write A for state [p, b] when the prediction subtracts the bias from odometry.
p⁺ = p + d − 0.1·b, b⁺ = b. So A = [[1, −0.1], [0, 1]] acting on [p, b], with d as the input.
Common mix-ups
You can only estimate what you measure.
✓ A good model links hidden states to measured ones; observable hidden states can be estimated.Tuning on your test runs is fine.
✓ That overfits Q and R to those runs. Tune on separate seeds, then report on held-out ones.
Practice
Practice, not a test. Answers are checked on our server; a wrong answer gets a hint and another try. Nothing is saved.
Apply it
Pre-register a small tuning study in the fusion lab: three Q settings, five seeds each, metric RMSE, decision rule 'lowest mean RMSE, ties broken by consistency'. Run it on seeds 1–5, then report the chosen setting's RMSE on seeds 6–10.
Reflect
What hidden state might a real rover estimate besides odometry bias?
Write your answer on paper or in your own notes. Lite never stores what you write.
Go further
Research mode: limits and open questions
A fair tuning protocol is part of an honest comparison: give every estimator the same tuning budget on separate training seeds, then report on held-out seeds.