Robot Foundations · Module 7: Knowing Where You Are
Dead Reckoning: Position from Counting Wheel Turns
Start from a pose you know, add up how far each wheel rolled, and you always have a pose. No map, no outside help.
Sailors crossing an ocean before satellites had no landmarks to look at. They knew where they had left, how fast they had sailed and in which direction, and for how long. From that they marked the ship's position on the chart, and moved the mark a little further every hour. They called it dead reckoning, short for "deduced reckoning". A robot does the same thing with its wheels. This lesson turns the formulas you already know into the update rule that runs on every step.
What you will be able to do
- Write the odometry update from the distance each wheel rolled.
- Explain why the update uses the middle heading of the step.
- Carry a pose forward through several steps by hand.
- State what dead reckoning needs and what it cannot do.
The idea
In the lesson Sensors That Look Inward: Encoders and Inertial Sensors two encoders gave the distance each wheel rolled during one step, dL and dR. In the lesson How a Two-Wheeled Robot Drives the average of the two gave the forward distance, and the difference over the wheel base gave the turn. Odometry puts them together and applies them to the pose, once per step.
Forward distance in the step, and the angle turned in the step.
ds = (dR + dL) ÷ 2
dθ = (dR − dL) ÷ L
L is the wheel base, 0.3 m for Pip.
The new pose: move ds along the middle heading of the step, and turn by dθ.
x = x + ds × cos(θ + dθ ÷ 2)
y = y + ds × sin(θ + dθ ÷ 2)
θ = θ + dθ
Each line replaces the old value of x, y and θ by the new one. Repeat on every step.
These are the same three lines as the motion model of the lesson Speed, Time and Small Steps, with two differences. The speeds v and ω are replaced by what the encoders measured, and the heading used for moving is the heading half way through the turn.
Why the middle heading?
While the robot moves ds it is also turning by dθ. Its heading goes from θ to θ + dθ, and it is pointing in each direction in between. The average direction, a good one to use for the whole step, is the middle: θ + dθ ÷ 2. Using the heading from the start of the step would send the whole step in a direction the robot only pointed in at the beginning. For small turns the difference is tiny. For a large turn in one step it is not.
| Way of placing the new pose | New x | New y | Off from the exact answer by |
|---|---|---|---|
| Exact (the true arc) | 0.219 | 0.172 | 0 |
| Middle heading (the update above) | 0.236 | 0.186 | 2.2 cm |
| Heading from the start of the step | 0.3 | 0 | 19 cm |
The middle-heading rule is about 9 times closer to the truth on a step this violent. That is why lab 5 asks for it, and why every robot uses it.
Dead reckoning: new pose = old pose + what the wheels say they did. The estimate is only ever the last estimate plus one small step.
What it needs, and what it gives
- A known start. The first pose has to be given. Odometry measures change, not position: it has no way of finding out where it started.
- The robot's dimensions. The wheel radius (to turn encoder ticks into distance) and the wheel base L. A wrong value is a wrong answer on every step.
- Nothing from the outside. No map, no sensor looking at the world. It works in the dark, in fog and in an empty corridor.
With perfect encoders and wheels that never slip, odometry is exact apart from the small error of using a straight line for each step. That is the first demonstration in lab 5. The next lesson is about why real robots do not get that.
Words to know
- Dead reckoning
- Working out a position from a known start by adding up the moves made since. On Pip: what its odometry does between sightings of anything known.
- Odometry
- Dead reckoning for wheeled robots: estimating the pose from wheel rotation. On Pip: the update_pose function of lab 5.
- Estimate
- The pose the robot believes it has. It is not the same as the true pose. On Pip: the pose the odometry holds.
- Step
- One pass of the update, for the distance each wheel rolled since the last one. On Pip: 0.05 s long for Pip's loop.
- Middle heading
- The heading half way through the turn of a step, θ + dθ ÷ 2, used to place the step. On Pip: it uses it in every step.
- Wheel base (L)
- The distance between the drive wheels. On Pip: 0.3 m.
A worked example: six steps of odometry
Pip starts at the pose (0.5, 0.5, 0°) and its wheel base is 0.3 m. The encoders report, for each step, the distance rolled by each wheel. Work through the first two steps.
Step 1: dL = 0.6 m and dR = 0.6 m.
- ds = (0.6 + 0.6) ÷ 2 = 0.6 m. dθ = (0.6 − 0.6) ÷ 0.3 = 0: straight.
- x = 0.5 + 0.6 × cos 0° = 1.1. y = 0.5 + 0.6 × sin 0° = 0.5. θ stays 0°.
Step 2: dL = 0.54 m, dR = 0.66 m.
- ds = (0.66 + 0.54) ÷ 2 = 0.6 m. dθ = (0.66 − 0.54) ÷ 0.3 = 0.4 rad = 22.9°, a left turn because the right wheel rolled further.
- The middle heading is 0° + 11.5° = 11.5°.
- x = 1.1 + 0.6 × cos 11.5° = 1.69. y = 0.5 + 0.6 × sin 11.5° = 0.62. θ = 0° + 22.9° = 22.9°.
Carry on in the same way and the table below is the whole run.
| Step | dL (m) | dR (m) | ds (m) | dθ | x (m) | y (m) | θ |
|---|---|---|---|---|---|---|---|
| 1 | 0.6 | 0.6 | 0.6 | 0° | 1.1 | 0.5 | 0° |
| 2 | 0.54 | 0.66 | 0.6 | 22.9° | 1.69 | 0.62 | 22.9° |
| 3 | 0.54 | 0.66 | 0.6 | 22.9° | 2.18 | 0.96 | 45.8° |
| 4 | 0.6 | 0.6 | 0.6 | 0° | 2.6 | 1.39 | 45.8° |
| 5 | 0.66 | 0.54 | 0.6 | -22.9° | 3.1 | 1.73 | 22.9° |
| 6 | 0.66 | 0.54 | 0.6 | -22.9° | 3.68 | 1.85 | 0° |
The right wheel rolled further in steps 2 and 3, so the pose turned left. In steps 5 and 6 the left wheel rolled further, so it turned back right and ended facing 0° again. The total distance is 3.6 m, the net movement 3.46 m.
Try it yourself
Pip (L = 0.3 m) is at (0, 0, 0°). In one step the left wheel rolls 0.30 m and the right wheel 0.36 m. (a) What are ds and dθ in degrees? (b) What is the new pose, using the middle heading?
Answer
(a) ds = (0.36 + 0.30) ÷ 2 = 0.33 m. dθ = (0.36 − 0.30) ÷ 0.3 = 0.2 rad = 11.5°, a left turn. (b) The middle heading is 5.7°. x = 0.33 × cos 5.7° = 0.328. y = 0.33 × sin 5.7° = 0.033. θ = 11.5°. The pose is (0.328, 0.033, 11.5°).
Common mistakes
"Odometry measures position."
It measures the movement of the wheels and works the position out from a given start. Without a known start pose, or if the start was wrong, every pose after it is wrong by the same amount.
"Use the old heading to move, then turn: it is simpler."
It is, and it is wrong whenever the turn in a step is not tiny. The middle heading costs one extra line and removes most of the error.
"If the update is exact, the estimate is exact."
The update is exact for the wheel distances it is given. The wheel distances are what the encoders report, not what the robot did, and the next lesson is about the difference.
Remember this
- ds = (dR + dL) ÷ 2 and dθ = (dR − dL) ÷ L.
- The pose moves by ds along the middle heading θ + dθ ÷ 2, then the heading turns by dθ.
- Dead reckoning needs a known start and the robot's dimensions, and nothing from outside.
- With perfect encoders and no slip it is exact. Real robots do not have either.
Check yourself
Three questions. Write an answer in your own words, then reveal the explanation. Nothing you type leaves your browser.
Question 1
A robot with a wheel base of 0.4 m rolls its left wheel 0.50 m and its right wheel 0.50 m in one step from (1, 2, 90°). What is the new pose?
Explanation
ds = 0.50 m and dθ = 0, so it drives straight along its heading of 90°, which is along +y. The new pose is (1, 2.5, 90°).
Question 2
The left wheel rolls 0.2 m and the right wheel 0.5 m. Which way does the robot turn, and by roughly how many radians if the wheel base is 0.3 m?
Explanation
The right wheel rolled further, so it turns left. dθ = (0.5 − 0.2) ÷ 0.3 = 1.0 rad, about 57°.
Question 3
Why does the odometry update use the heading half way through the step?
Explanation
During a step the robot is turning, so it points in a range of directions between the start and end headings. The middle one is the best single direction to place the whole step. The start heading would be wrong by half the turn, and the error grows with the size of the step and the size of the turn.
What’s next
Dead reckoning is exact on paper. The next lesson shows what it does on a real floor, with wheels that slip and encoders that are not quite right.
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.