An error budget
Predicting how far out you will be before you drive, which is what covariance is for.
Do this lesson in the simulatorPrint it: worksheet (PDF) · answers (PDF) · as a web page
Guide: Dead reckoning and odometry explained
Before driving, an engineer can usually say how far out the robot will be at the end. That prediction is an error budget: each source of error, how much it contributes, and the total.
It is worth doing because it tells you what to fix. Spending a week on the noise when the bias is five times larger is a week wasted, and the budget shows that before the week starts.
A budget for a 2 m straight run
| Source | Size | What it costs over 200 cm |
|---|---|---|
| gyro bias, uncalibrated | 0.19 deg/s over 10 s = 1.9 deg by the end | 200 * 0.017 = 3.3 cm sideways |
| gyro bias, calibrated | 0.025 deg/s left over = 0.25 deg by the end | about 0.4 cm sideways |
| flow scale | 3 percent | 6 cm along |
| flow noise | 0.7 cm/s, 100 steps | about 0.7 cm, random walk |
| slip | a guess: 1 percent | 2 cm, direction unknown |
The sizes are this robot's. Its gyro reads about 0.19 deg/s when still. The 4 second average from U3.4 measures -0.17, which leaves 0.025 deg/s behind after calibration. Its flow sensor reads about 3 percent high going forwards.
The heading rows use half the final heading error, because a bias makes the heading error grow steadily from nothing: on average over the run it is about 1 degree, not 1.9. That is why the bias term grows with the square of the time: the same bias over a one minute run is 36 times as much, about 1.2 m sideways.
Read that table and two things stand out. Over 2 m the scale error is already the biggest term, so it is the thing to attack. The bias comes second, but only because the run is short: over a minute it costs 1.2 m against 36 cm of scale. Calibrating the gyro costs a few seconds of standing still, so do it every time.
Adding the pieces up
Independent errors add in quadrature, not directly: the total is the square root of the sum of the squares. Two 3 cm errors make about 4.2 cm, not 6, because they are unlikely to be at their worst in the same direction at once.
from bugbot import *
import math
connect()
pieces = {"heading": 0.4, "scale": 6.0, "noise": 0.7, "slip": 2.0}
total = math.sqrt(sum(v * v for v in pieces.values()))
for name, v in pieces.items():
print(name.ljust(8), v, "cm")
print("total ", round(total, 1), "cm")
Note what quadrature does to the small terms. The noise contributes 0.7 cm on its own and changes the total by less than a millimetre. Anything much smaller than the largest term is not worth working on, which is the most useful thing a budget tells you.
This is covariance, informally
A budget is a statement about a distribution: not "I will be 6.4 cm out" but "I will be within about 6.4 cm, most of the time, and further out mainly along the direction I drove".
That last part matters. The error is not a circle. Scale error stretches along the direction of travel, heading error throws you sideways, and after a long straight the uncertainty is a long thin ellipse rather than a disc. A filter that carries a full covariance matrix carries exactly that ellipse, and that is the machinery of U6.5.
Task: an error budget
Print what you expect the dead reckoning error to be over your run, as predicted error:, before you drive. Then drive at least 90 cm and print actual error:, the real gap between odometry() and position().
from bugbot import *
import math
connect()
DISTANCE = 100.0
Challenges
- Run the same thing at
set_noise(3)and see which line of the budget you should have tripled. - Budget a run with four corners in it. What changes?
- Repeat the run ten times and compare the spread of the actual errors with your predicted number.