Lite / Textbooks / Robotics From First Principles / Chapter 8
8. Where am I? Drift, uncertainty and fusion
Introduction
Counting wheel turns tells a robot how far it has gone, until a wheel slips. Dead reckoning drifts, and the error only grows. A beacon or camera fix is noisy but does not drift. The answer is to keep a belief with an uncertainty attached, predict it forward with the motion model, and correct it with each measurement, weighting each source by how much it can be trusted. That is the predict–update cycle.
Figure 8.1. Two uncertain guesses, one better one (described in words)
Three bell curves: odometry says 4 m with σ 0.4 m, a beacon says 4.6 m with σ 0.3 m. Fusing them with gain K = 0.64 gives 4.384 m with σ 0.24 m, a narrower curve than either source.
Explanation
Built from 4 School lessons. Each part is the lesson's own explanation.
8.1 Accurate, precise, both or neither
Five readings that agree to the millimetre can all be 3 cm wrong. How would you ever know?
Two different questions
Accuracy: is the average reading close to the true value? Precision: do repeated readings agree with each other? They are independent. A bathroom scale that always reads 2 kg heavy is precise and inaccurate; a cheap thermometer whose readings jump around a correct average is accurate on average and imprecise.
Bias moves, noise spreads
A systematic error (bias) shifts every reading the same way: a zero offset, a mis-set gain, a sensor warmed by its own electronics. A random error scatters readings unpredictably: electrical noise, vibration, quantisation. Bias damages accuracy; noise damages precision.
You need the truth to see bias
You can measure precision from the readings alone: just look at their spread. Accuracy needs a reference: a known weight, a measured distance, a calibrated instrument. Without one, a biased sensor looks perfectly healthy. This is why calibration rigs exist.
Common mix-ups
Precise readings must be accurate.
✓ A tight group can sit far from the truth. Only a reference reveals bias.Averaging fixes every kind of error.
✓ Averaging shrinks random error. Bias survives any amount of averaging.
Open the Lite lesson: Accurate, precise, both or neither
8.2 Dead reckoning and why it drifts
Count every wheel turn perfectly and you still end up metres from where you think you are. Where does the error come from, and how fast does it grow?
Integration accumulates
Dead reckoning adds up measured steps: x[k] = x[k−1] + d[k]·cos θ[k], y[k] = y[k−1] + d[k]·sin θ[k]. Any error in d or θ is added in and never removed. The estimate's uncertainty can only grow until an absolute measurement arrives.
Three growth laws
A scale bias (wheels over-reading by fraction s) gives along-track error s·d: linear in distance. A constant heading error θ₀ gives cross-track error d·sin θ₀: also linear. A heading drift rate b (gyro bias) makes the heading error grow with time, so cross-track error grows like ½·v·b·t². Independent random step errors grow only like √n.
Living with drift
The cure is not a perfect wheel but an occasional absolute fix: a landmark, a sun sensor, an orbital image. A drift model tells you the spacing: if heading drift adds 1 m of error every 100 m and the corridor allows 2 m, fix at least every 200 m, with margin.
Common mix-ups
Better wheel encoders fix dead reckoning.
✓ Encoders count turns; slip and heading drift are errors in what the turns mean. Only absolute references remove accumulated error.All odometry error grows like √n.
✓ Random error does. Biases grow linearly or faster, and they dominate long drives.
Open the Lite lesson: Dead reckoning and why it drifts
8.3 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.
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.
Common mix-ups
A low RMSE proves the filter is right.
✓ It must also be consistent: its own σ should match its actual errors, or downstream decisions will be over- or under-cautious.The update step can increase uncertainty.
✓ For a correct linear-Gaussian model P = (1 − K)P⁻ is always smaller than P⁻. A surprising measurement moves x a lot, but P still shrinks.
Open the Lite lesson: The predict–update cycle
8.4 Navigation uncertainty ellipses and budgets
'Within 5 km' is not one number. Along the track you may know 4 km; across it, 1.5 km; and the two errors may be linked. Draw that and you get an ellipse.
Covariance to ellipse
Position error [eₓ, e_y] has covariance Σ = [[σₓ², ρσₓσ_y], [ρσₓσ_y, σ_y²]]. Contours of equal probability are ellipses whose axes are Σ's eigenvectors and whose 1σ semi-axes are √(eigenvalues). With ρ = 0 they line up with x and y; correlation tilts them.
Choosing the probability
For a 2-D Gaussian, the probability inside the ellipse scaled by k is p = 1 − e^(−k²/2), so k = √(−2 ln(1 − p)): k = 1 → 39%, 2 → 86%, 2.45 → 95%, 3.03 → 99%. Always state which ellipse you mean: '3σ' and '99%' are different in 2-D.
Budgets and zones
A navigation budget combines contributions (in each axis, by RSS if independent) into Σ. The design check: the p-ellipse must fit inside the safe zone with margin. If it does not, either shrink the uncertainty (more fixes, better sensors) or choose a bigger, safer zone.
Common mix-ups
2σ means 95% in any number of dimensions.
✓ Only in 1-D. In 2-D, 2σ holds about 86%; 95% needs about 2.45σ.A small σ in one direction means the position is well known.
✓ The ellipse is only as useful as its longest axis allows; and correlation can make the worst direction diagonal.
Open the Lite lesson: Navigation uncertainty ellipses and budgets
Worked examples
Accurate, precise, both or neither: example 1
A 100.0 g reference mass is weighed five times: 101.9, 102.1, 102.0, 101.8, 102.2 g. Describe accuracy and precision.
Solution
Mean = 102.0 g, so bias = +2.0 g (poor accuracy). Readings span only 0.4 g, so precision is good. Fix: subtract 2.0 g, then re-check with another reference.
Dead reckoning and why it drifts: example 1
Wheels over-read by 3%. Distance 100 m. Along-track error?
Solution
0.03 × 100 = 3 m. The rover thinks it is 3 m further along than it is.
The predict–update cycle: 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.
Solution
x⁻ = 1, P⁻ = 1.25. K ≈ 0.714. x ≈ 1.43 m, P ≈ 0.357 m² (σ ≈ 0.60 m).
Navigation uncertainty ellipses and budgets: example 1
σₓ = 4 km, σ_y = 1.5 km, independent. Will the 95% ellipse fit a zone 20 km long by 10 km wide?
Solution
k = 2.448. Half-extents 9.79 km (≤ 10) along and 3.67 km (≤ 5) across: it fits, with only 0.21 km to spare along track.
Interactive figures, in words
Figure 8.2 from Dead reckoning and why it drifts
Start with only 3% slip bias and no heading drift: double the steps and check the error doubles. Now set slip to 0 and heading drift to 0.1° per step: double the steps and watch the error roughly quadruple. Finally use noise only, and compare how slowly random error grows.
The drift rover draws the straight true track and the dead-reckoned track; the readout states the final error and the bias-only predictions for along-track and cross-track error.
Figure 8.3 from The predict–update cycle
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.
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.
Laboratory
These run in a browser on the full site (they need a faster connection). Simulations are simplified educational models.
- Simulation OS: Two-sensor fusion (Simulation OS experiment)
Fuse drifting odometry with a camera that drops out and compare the fused error with each sensor alone.
Open on the full site - Playground: Sensor fusion (Playground lab)
Change one sensor's noise and predict which way the fused estimate moves before you look.
Open on the full site - BUILD: Planetary rover, level 3 (BUILD level)
Decide which sensor to trust on sand and which on firm ground, and justify each choice.
Open on the full site
Practice
Each question links to its Lite lesson, where your answer is checked on our server and a wrong answer gets a hint. Answers are never sent to your device.
- Readings: 49.1, 50.8, 48.7, 51.5, 49.9 for a true value of 50. Which describes them?
Answer it in “Accurate, precise, both or neither” - A 20.0 cm gauge block measures 20.6, 20.4, 20.5, 20.5 cm. What is the bias, in cm?
Answer it in “Accurate, precise, both or neither” - Odometry over-reads distance by 4% because of slip. After 250 m, what is the along-track error, in metres?
Answer it in “Dead reckoning and why it drifts” - With a constant gyro DRIFT RATE (heading error growing steadily), doubling the drive time at constant speed makes the cross-track error…
Answer it in “Dead reckoning and why it drifts” - After predicting, a 1-D Kalman filter's variance is P = 1 m². The camera measurement variance is R = 2 m². What is the Kalman gain K?
Answer it in “The predict–update cycle” - In simulation, the true position leaves the filter's ±2σ band on 40% of steps. The most likely problem is…
Answer it in “The predict–update cycle” - A landing-position error budget has four independent 1σ contributions: entry navigation 2 km, atmosphere 4 km, aerodynamics 5 km and timing 1.5 km. What is the combined 1σ error (root-sum-square), in km?
Answer it in “Navigation uncertainty ellipses and budgets”
Engineering applications
Phones and cars
Phone maps blend satellite fixes, motion sensors and wheel or step counts. In a tunnel the satellite fixes vanish and the estimate coasts on motion sensors, with its uncertainty growing until the next good fix.
Mars rovers
Rovers cannot ask Earth where they are in real time. They combine wheel odometry, inertial sensors and visual matching of the terrain, and stop to re-localise when slip makes odometry untrustworthy.
Watch (optional)
Streaming video uses a lot of data. Everything you need is in the text.
- “Why Use Kalman Filters? | Understanding Kalman Filters, Part 1” by MATLAB
- “How Perseverance Learned to ‘Self-Locate’ on Mars” by NASA Jet Propulsion Laboratory
- “Optimal State Estimator Algorithm | Understanding Kalman Filters, Part 4” by MATLAB
Summary
- Dead reckoning integrates motion, so small errors accumulate and the position drifts.
- Keep an estimate together with its uncertainty, not a bare number.
- Predict with the motion model (uncertainty grows), then update with a measurement (uncertainty shrinks).
- The gain weights each source by its trust: K = P / (P + R) for a single quantity.
Glossary
- Odometry
- Odometry estimates a robot's position and heading by adding up how far its wheels have turned since a known start. Field Guide
- Encoder counts and resolution
- A rotary encoder reports rotation as a count of ticks. Its resolution is the number of counts per revolution (CPR), often four times the pulses per revolution with quadrature decoding. Field Guide
- IMU (inertial measurement unit)
- An IMU combines an accelerometer, which measures acceleration including gravity, and a gyroscope, which measures angular velocity; some add a magnetometer. Field Guide
- Random and systematic error
- Random errors scatter readings unpredictably above and below the true value; systematic errors shift every reading the same way. Field Guide
- Standard deviation
- Standard deviation measures how spread out values are around their mean: the square root of the average squared distance from the mean. Field Guide
Project: A one-dimensional localiser
Simulate a robot driving along a corridor with noisy wheel odometry and a beacon that gives a noisy position every few seconds. Implement the predict–update cycle for position alone, plot the estimate and its uncertainty band against the truth, and report how the error compares with odometry alone.
Deliverables
- The simulation and filter code with fixed random seeds
- A plot of truth, odometry and fused estimate with its band
- Error statistics for both methods and an honest limitation
Write it up on paper or in your own notes. Lite never stores what you write.
References
- Sebastian Thrun et al. (2005). Probabilistic Robotics. MIT Press.
- R. E. Kalman (1960). "A New Approach to Linear Filtering and Prediction Problems". Journal of Basic Engineering 82(1), 35–45.
- Roland Siegwart et al. (2011). Introduction to Autonomous Mobile Robots, 2nd edition. MIT Press.