Part 2 · How robots sense

19Odometry: where am I, and why wheels lie

A rover with its eyes shut can still say where it is, by counting what its wheels have done. Watch its belief ride on the truth for a whole square, then oil one wheel and watch the two come apart by a meter.

This assumes: Wheels: how rovers turn with no steering wheel. About 9 minutes of reading.

Shut your eyes in the middle of a room you know and walk: ten paces forward, a quarter turn to the left, ten more. You can still point to where you are, roughly, because you counted. A robot with no camera on its nose does the same, many times a second, and this module is about how good that count is, how it goes wrong, and why the robot cannot tell when it has.

Counting your way

The rover has a sensor on each wheel's axle that counts how far that wheel has turned; the "turning" number in the module about wheels came from it. Odometry is working out how far the robot has moved, and which way, from how far its wheels have turned. It is your eyes-shut sum done with wheels instead of paces.

The sum is the one from the module about wheels. Every radian a wheel's sensor counts is one radius, 5 centimeters, of floor gone by. The body sits midway between the wheels, so it has moved by the average of the two distances, and the difference between them, across the 19 centimeters between the wheels, is how far the body has swung, in radians, toward the slower wheel.

That gives a step and a swing, but not yet a place. For a place, the robot keeps three numbers: how far across and how far up it is from some fixed spot, and its heading, the direction its nose points, as an angle. Many times a second it reads the two wheel counts, works out the little step and the little swing since the last reading, takes the step in the direction it is currently facing, and adds the swing to its heading. A step taken at a slant is partly across and partly up, and the heading says in what split. Tell the robot where it starts, and from then on the three numbers are its belief about where it is.

That way of keeping track has a name from the sea. Dead reckoning is knowing where you are by starting from a place you knew and adding up every move you have made since, with nothing checking the sum against the world. The word to hold onto is adding: nothing in the sum ever looks at the room, so a step counted wrong stays in the total for ever, and every step after it is taken from the wrong place.

Why wheels lie

A wheel's sensor counts the wheel. It cannot count the floor. The two agree only while the wheel grips, and a wheel grips only as hard as the floor lets it. Rolling along at a steady speed takes almost no push, because a rolling wheel's drag is tiny, as the module about wheels found. A wheel that has to push hard, to speed up, to slow down or to swing the body round, asks the floor for grip, and if the floor has less to give, the wheel turns without the floor going by. That is a slip.

The big version is plain. Push the rover against a wall, as you did in the module about wheels, and the wheels go on turning while the body stands still: the count goes up, the floor does not go by, and the sum says the rover drove through the wall. A wheel on oil or a wet tile does the same whenever it has to push: it spins a little more than it rolls, and the count records the spin as distance.

The small version is everything else. The wheel is not exactly 5 centimeters, because its tire wears and squashes; the two wheels are not exactly alike; the spacing is not exactly 19. And every turn costs a little. A wheel's tread is a few centimeters wide, and in a swing its inner and outer edges are carried round circles of different sizes at one speed, so one of them scrapes across the floor, a scrub. The rover also rocks as a turn starts and stops, which lifts weight off one wheel, and a lightly loaded wheel grips less. That is why the spin in the module about wheels came out a few percent under the arithmetic.

The problem is that nothing cancels them. A robot 3 degrees wrong about its heading takes every step after that 3 degrees wrong, and since a radian is one radius of travel, the gap it opens is the angle in radians times the distance driven: 3 degrees is a twentieth of a radian, so a meter later the gap is 5 centimeters and ten meters later half a meter. That is what makes heading mistakes the expensive ones. The slow wandering of the belief away from the truth, as small errors pile up with nothing to correct them, is drift, and dead reckoning drifts by its nature.

The box

The box below holds the rover in its pen, seen from the near side: it starts in the bottom left corner facing right, and "up" in the numbers means up the screen. The beacon is there, but the rover is not looking for it: its brain reads nothing about the world outside, and the wheel counts only keep the belief. It drives a square on a clock, forward for three and a bit seconds, a slow quarter turn to the left over a second and a half, forward again, round and round. On the legs both wheels are told 6 radians a second, 30 centimeters a second; in the turns, 2 radians a second in opposite directions. The wheels settle a little short of what they are told, as in the module about wheels, so each leg is a little under a meter and each turn a little under a quarter.

Two lines are drawn on the floor. The gray one is where the rover really went. The orange one is where the rover believes it went, worked out from nothing but the two wheel counts, with an orange arrow at its end pointing the way the rover believes it faces. Under the box, a panel writes the same as numbers: "Believes", the rover's three numbers, and "Really", the true ones. Positions are in centimeters from the middle of the pen, across the screen and then up it, so the starting corner reads (−67, −50); the facing is in degrees, 0 pointing right, counting counterclockwise, so 90 is up the screen. A line under the two says how far apart they are, in centimeters and in degrees.

One button puts oil under the left wheel: its grip drops to a twentieth, and the wheel glows blue to say so. Reset puts the rover back in its corner, wipes both lines, sets the belief to the truth, and takes the oil away.

Loading the simulation. The robot runs in your browser, so the first one takes a few seconds to arrive.

This is easier on a larger screen, but it works here too.

What you saw

For most of the first leg the belief was the truth: dead reckoning is good, to a centimeter over a meter of clean floor, with no camera and no map. Look closely, though, and the belief was already a centimeter ahead: getting up to speed, the wheels pushed harder for a fraction of a second than a clean floor holds, and spun faster than the floor went by. Each turn then cost a degree or so of scrub, a little different each time because the rover rocks differently each time. A leg driven a little off is partly undone by the leg back, so round a square the errors happen to half cancel. That is luck, not correction, and it is why three squares left the heading five or ten degrees out and the position a hand's width.

Then the oil. On the straight leg it did nothing, and that is not luck: a steady roll takes a tiny push, and a twentieth of the grip still carried it. The slip came when the wheel had to push. At the turn the left wheel is told to go from 6 radians a second forward to 2 backward, the biggest change the clock ever asks, and a motor pushes in proportion to how far the wheel is from the speed it was told. On the oil it could not push against the floor, so it spun, and its sensor counted every bit of the spin as road.

The truth turned late and short because one wheel was swinging the body instead of two: a wheel with no grip can no more brake its side than drive it, so for a moment the left side rolled on while the right slowed, nudging the rover the wrong way before the right wheel's push took over. As the next leg began, the right wheel took hold first and swung the rover left again, making up part of what was missed. Add it up: about 25 degrees short of the belief's 85, and a heading error is the expensive kind. Every centimeter of the next leg was taken at that angle, 40 centimeters of scissors by the end of it, and the oil stays, so every turn after that adds another slice, and 25 degrees becomes a meter within a square.

Now notice who is reading the panel line that says a meter. You are. The rover cannot: the truth is there because the simulation knows, and a real rover has no simulation to ask. All the robot has is the orange arrow, the arrow is a sum, and the sum does not know it is wrong.

Living with it

Real robots do three things about this. First, they calibrate: drive a measured meter and a measured turn, compare the count with the tape, and correct the wheel size and the spacing until the sum comes out right; the video under these words shows a person doing it on a bench. That removes the small, steady errors and does nothing about slips. Second, they add a small chip that feels rotation, the kind that tells a phone it has been turned on its side, so a slipping wheel can no longer lie about the heading, only about the distance.

Third, the real answer: they look at something that does not move. A wall measured by a distance sensor, a doorway seen by a camera, the beacon: anything fixed that the robot can sense is a chance to compare the belief with the world and correct the sum. This rover cannot, because its brain reads nothing, and that is why its belief could not come back. Dead reckoning is what the robot trusts in between: from one glance at a landmark to the next, the wheels are all it has, and over that stretch, as you saw, they are good.

What the simulation leaves out

The floor here is perfectly flat, the wheels perfectly round, the spacing and the counting exact, so the only errors are the ones the physics makes: a little skid getting going and a little scrub in the turns. A real rover's errors are bigger and more varied, and the oil button stands in for all of them: a rug edge, a wet patch, a bump. A slip is invisible to the count, it lands hardest on the heading, and the belief never heals on its own.

Watch

Mark 01 - Differential Robot #4 : Odometry and PID Controller — GusBots (5:40 of it, starting at 0:00)

Why this video
A real two-wheeled robot on a real floor, told where to go and steering there by nothing but its wheel counts, the way the rover in the box does: it manages a one-meter square about as well as the rover, gets thoroughly lost on a four-meter one, and its builder says out loud that wheel counts alone are "not a good technique, errors accumulate pretty fast". Then he calibrates it by hand, pushing it along a meter of tape and counting ticks, and pushing one wheel round a full turn to measure the spacing, which is the first of the three fixes in the words done on a kitchen bench.
What to watch for
At 1:21 the first run, "not so bad", and at 2:14 it goes to (2, 2) and back, twice: the second time, at 3:14, it "gets completely lost and crashes". At 3:23 the one-meter square, close to the rover's; at 3:47 the four-meter square, "the robot got pretty lost at the end". From 4:45 the calibration: a meter of tape on the bench, the robot pushed along it by hand while the count is read (194 ticks), and at 5:15 one wheel pushed round a full turn so the heading reads 360. From 0:52 to 1:41 he sets up a terminal and a joystick, which you can skip.

Words introduced

odometry
Working out how far a robot has moved, and which way, from how far its wheels have turned. The word means "road measuring".
dead reckoning
Keeping track of where you are by starting from a place you knew and adding up every move you have made since, with nothing checking the sum against the world.
heading
The direction a robot's nose points, as an angle on the floor.
drift
The slow wandering of a robot's belief about where it is away from where it really is, as small errors pile up with nothing to correct them.

Where next

Suggested next: 20. Noise: why every sensor lies a little, and how averaging helps — Two rovers with the same shaky sensors drive at the same box. One believes every reading and flinches at a box that is not there yet; the other believes the average of the last few, and drives smoothly. Then make it average too much, and watch it turn too late.