An error budget
Predicting how far out you will be before you drive, which is what covariance is for.
Do this lesson in the simulatorBefore 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 ten 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.4 deg/s over 10 s = 4 deg | 200 * 0.07 = 14 cm sideways |
| gyro bias, calibrated | 0.05 deg/s = 0.5 deg | about 1.7 cm sideways |
| flow scale | 4 percent | 8 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 |
Read that table and the conclusion is immediate: calibrate the gyro, and after that the scale error is the thing to attack.
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": 1.7, "scale": 8.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 8.4 cm out" but "I will be within about 8.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.