Robot Foundations · Module 7: Knowing Where You Are
Predict, Then Correct
Predict with motion, correct with a measurement, and repeat. The error grows during the first step and shrinks in the second.
Two sources of information, each with a weakness. Odometry is smooth and always available, and it drifts without limit. A landmark sighting has no drift and is noisy and only available now and then. Used alone, each fails. Used together, in a repeating cycle, they do something neither can do alone: they keep the error small for as long as the robot runs. The cycle has two steps and a name, and it is the idea at the heart of almost every estimator in robotics.
What you will be able to do
- Describe the predict step and the correct step, and what each does to the error.
- Compare the error with no corrections, occasional corrections and frequent corrections.
- Explain how the trust placed in an observation, α, trades speed against jitter.
- Say why the best α depends on how much the estimate has drifted.
The idea
The cycle:
- Predict: move the estimate with the wheels (odometry). The error grows.
- Correct: when a landmark is seen, pull the estimate toward the observation. The error shrinks.
- Predict again…
- Predict. On every pass, the odometry moves the estimate by what the wheels report. This uses the robot's own motion, and it is how the estimate stays up to date between sightings. It makes the estimate worse a little each step: the drift of the lesson Why Drift Grows.
- Correct. When something known is seen, the estimate is moved toward the observation, as in the lesson Landmarks: Correcting with Something You Recognise. This makes the estimate better.
Predict with motion, correct with a measurement. The error rises between sightings and drops at each one, so it never gets far.
Everything you will meet later is a version of this cycle: the filters taught on the Probability track, particle filters, and the localization inside every SLAM system. They differ in how they hold the estimate and how they choose the blend. The cycle is the same.
What the corrections do to the error
Take a 40 s drive, 20 m, with the wheels slipping about 10% and noisy encoders, so that odometry alone drifts. Now give the robot landmark sightings at different rates and see what happens to the position error. (The simulation assumes a landmark is always in view, which is kinder than a real floor. In the lab the sightings stop beyond 4 m.)
| Landmark sightings | α | Mean error | Largest error |
|---|---|---|---|
| Never | not used | 4.32 m | 12.33 m |
| Every 4 s | 0.1 | 2.71 m | 6.78 m |
| Every 4 s | 0.5 | 0.49 m | 0.94 m |
| Every 4 s | 1 | 0.16 m | 0.41 m |
| Every 1 s | 0.1 | 0.88 m | 1.47 m |
| Every 1 s | 0.5 | 0.1 m | 0.22 m |
| Every 1 s | 1 | 0.1 m | 0.26 m |
The effect is enormous. With no sightings the mean error over the drive is 4.3 m and the largest is 12.3 m. One sighting every 4 s with α = 0.5 brings the mean down to 0.49 m, and one every second to 0.1 m: about 43 times better than no sightings. The robot has not become more accurate. It has become bounded: it never gets lost further than the next sighting can fix.
How much to trust the observation
The blend α is a judgement about two uncertainties: how far the estimate may have drifted, and how noisy the observation is.
- If the estimate is very uncertain (a long time since the last sighting) and the observation is good, trust the observation: α near 1.
- If the estimate is already good (corrected a moment ago) and the observation is noisy, trust the estimate: α small, or the noise of the observation gets copied in.
The table shows both. With a sighting every 4 s the estimate has drifted a lot by then, and α = 1 does best (mean error 0.16 m against 0.49 m for α = 0.5 and 2.71 m for α = 0.1). With a sighting every second the estimate has barely drifted, and α = 0.5 does as well as α = 1.0 (0.1 m against 0.1 m) while jumping about less, with the largest error of 0.22 m against 0.26 m.
A sensible rule weighs each by how small its error is. If the estimate's typical error is e and the observation's is o, then:
A good α is the estimate's squared error divided by the sum of both squared errors.
α = e² ÷ (e² + o²)
e is how far the estimate may be off, o how far the observation may be off. This is a rule of thumb here. The Probability track derives it properly and updates e after every step.
| Estimate uncertain by | Observation uncertain by | Suggested α |
|---|---|---|
| 100 cm | 8 cm | 0.99 |
| 50 cm | 8 cm | 0.98 |
| 20 cm | 8 cm | 0.86 |
| 10 cm | 8 cm | 0.61 |
| 5 cm | 8 cm | 0.28 |
When the estimate is a metre out and the observation 8 cm, trust the observation almost completely. When the estimate is 5 cm out, trust it, and take only a quarter of the observation. The filters of the Probability track keep track of e as the robot drives, so that α is chosen well at every step.
This is the idea behind the whole of state estimation: keep an estimate and a measure of how uncertain it is, predict with motion (uncertainty grows), correct with measurements (uncertainty shrinks), and weigh by the uncertainties.
Words to know
- Predict step
- Moving the estimate with the robot's own motion. The estimate gets less certain. On Pip: the odometry update on each pass.
- Correct step (update)
- Pulling the estimate toward a measurement. The estimate gets more certain. On Pip: applied at each landmark sighting.
- Estimator (filter)
- A program that keeps an estimate by repeating predict and correct. On Pip: the loop of lab 5, in its simplest form.
- Alpha (α)
- The fraction of the gap closed by a correction: how much the observation is trusted. On Pip: a slider in lab 5.
- Bounded error
- An error that stops growing because corrections keep pulling it back. On Pip: the result of regular sightings.
- Uncertainty
- How far an estimate may be from the truth, as a typical size. On Pip: about 8 cm for an observation, growing for odometry.
A worked example: choosing α and the rate
Pip drives a 20 m corridor with a landmark in view the whole way. Its odometry drifts. The observation is good to about 8 cm. A sighting can be taken every 4 s or every second.
- With no sightings. The mean position error over the drive is 4.3 m and the largest 12.3 m: the robot is lost.
- A sighting every 4 s. Between sightings odometry drifts for 4 s. Even with full corrections the largest error is 0.41 m, so take e as about 0.3 m, well above the observation's 8 cm. The rule gives α = 0.93: close to 1. Check: at α = 1 the mean error is 0.16 m, at α = 0.5 it is 0.49 m and at α = 0.1 it is 2.71 m. The rule was right: the small α is far too timid, because it still has most of the drift left when the next sighting arrives.
- A sighting every second. Now the estimate has had one second to drift, so take e as about 0.1 m, close to the observation's 8 cm. The rule gives α = 0.61, a middle value. At α = 0.5 the mean error is 0.1 m, as good as at α = 1.0 (0.1 m), but with a smaller worst case (0.22 m against 0.26 m). Copying the whole observation brings its noise in with it.
- The choice. Sightings every second with α = 0.5 are the best here, and need the landmark in view every second. If sightings can only come every 4 s, use α near 1. The cheaper cure for a poor sighting rate is a higher α, and the cheaper cure for noisy sightings is a lower one.
The slider of lab 5 lets you see this with your own eyes: set α to 0.1 with occasional updates and the error climbs and recovers slowly, and set it to 1 and the estimate snaps to each observation.
Try it yourself
You are walking down a long, dark corridor counting steps. Every 20 steps you pass a door with a number you can read. (a) Between doors, what are you doing: predicting or correcting? (b) At a door, what do you do, and what happens to your uncertainty? (c) How would your plan change if a door appeared every 5 steps, or only every 100?
Answer
(a) Predicting: your count of steps moves your idea of position, and your uncertainty grows with every step because your stride is not exact. (b) You correct: you replace your count with the door number, so your uncertainty falls to what the door gives you, and you carry on counting from there. (c) With a door every 5 steps you hardly need to count at all, and you can take the door number at face value. With a door every 100 steps your count could be 10 or 20 steps out by the time you reach it, so the door deserves complete trust, and between doors you cannot rely on your count for anything fine.
Common mistakes
"If I trust the observation fully, the error will be as small as the observation's."
It is, but each sighting then copies the observation's noise, so the estimate jumps. When the estimate is already good, a smaller α gives a steadier and slightly better result.
"Corrections make odometry unnecessary."
Sightings are rare. Between them the estimate moves with the wheels. Without odometry the estimate would stand still, or have no idea of motion, until the next sighting.
"The best α is a fixed number I can set once."
It depends on how uncertain the estimate is, which changes: after a long gap it should be high, just after a correction low. A good estimator adjusts it on every step.
Remember this
- Predict with motion (error grows), correct with a measurement (error shrinks), and repeat.
- Regular corrections bound the error: here the mean error over a drive falls from several metres to about ten centimetres.
- α is how much the observation is trusted. Trust it more when the estimate has drifted far, less when the estimate is good and the observation is noisy.
- A rule of thumb for α: e² ÷ (e² + o²). Proper estimators keep track of e and choose α at every step.
Check yourself
Three questions. Write an answer in your own words, then reveal the explanation. Nothing you type leaves your browser.
Question 1
Between landmark sightings, a robot's estimate of its position gets steadily worse. Which step of the cycle is responsible, and which step fixes it?
Explanation
The predict step, odometry, makes it worse a little at a time, because it adds the wheels' errors to the estimate. The correct step, at a landmark sighting, pulls the estimate back toward a measurement that does not drift.
Question 2
An observation is good to 10 cm. The estimate is currently uncertain by 30 cm. Use α = e² ÷ (e² + o²) to suggest α.
Explanation
e = 0.30 and o = 0.10, so α = 0.09 ÷ (0.09 + 0.01) = 0.9. The estimate is much less certain than the observation, so the observation should be trusted almost fully.
Question 3
Why would setting α = 1 on every sighting make the position estimate jittery even when the robot is standing still and seeing the same landmark?
Explanation
Each observation has a small random error. With α = 1 the estimate is replaced by the latest observation each time, so it follows the observation's noise, jumping a few centimetres from sighting to sighting. With a smaller α the noise is averaged over many sightings, giving a steadier estimate.
What’s next
That completes everything the robot needs: it moves, senses, plans, maps and knows where it is. Lab 5 asks you to build it: write the odometry in Python, watch it drift, and add landmark corrections. After the lab, module 8 shows how all these parts run together as one system.
Where this goes on the site
Nothing below is needed to continue this course. These pages take the topic of this module further, and most assume more mathematics or Python than this course does.
- LaterLocalization & SLAM
Localization with real sensors and real maps.
- LaterProbability for Robotics
Predict and correct, derived: Bayes, Kalman and particle filters.