# Robot odometry drifts: calibrate wheel diameter, track width and ticks per turn

> Fix odometry that goes off: measure the real wheel diameter and the track width, count encoder ticks per turn and test straight and spin runs.

Canonical: https://roboticsengineering.in/fix/odometry-drifts-wheel-diameter-track-width-calibration/ | Published: 2026-11-03 | Updated: 2026-11-04

**Most odometry error comes from three numbers: wheel diameter, track width and ticks per wheel turn.** Measure them on your own robot.

## What the message means

Distance is ticks times the wheel circumference over ticks per turn. A wheel diameter that is off by 1 mm adds error at every metre, and a wrong track width spoils every turn.

## Fix it in this order

1. Measure the wheel diameter with a caliper, then confirm by rolling the robot a known distance.
2. Count the ticks for one full wheel turn by hand.
3. Drive straight for 2 metres and compare the reported and real distance, then adjust the diameter.
4. Spin in place for ten turns and adjust the track width until it returns to the start heading.
5. Check that left and right wheels use the same scale.
6. Expect drift anyway, and correct it with a gyro or other sensors.

## Why it happens

Odometry turns encoder ticks into distance, so any error in the numbers behind that conversion repeats on every metre. Here is an illustrative example: a 65 mm wheel measured 1 mm too large is about 1.5 percent off, which is roughly 1.5 cm of error per metre driven. Track width errors do the same to turns, because the turn angle comes from the difference between the wheels divided by the track.

Wheel slip, uneven floors and tyre squash cannot be calibrated away, so odometry drifts over time even when the numbers are right. That is why robots combine it with a gyro or other references.

## If you see this, do this

| You see | Do this |
| --- | --- |
| Straight line distance is off | Wheel diameter or ticks per turn. |
| Turns are off | Track width. |

## Related

[differential drive odometry guide](https://roboticsengineering.in/differential-drive-odometry-guide/), [encoder gives no pulses](https://roboticsengineering.in/fix/gear-motor-encoder-no-pulses-hall-power/).

Last reviewed: November 2026. These are the usual causes and the order that finds them fastest. Test on your own board; clones and cables differ.

## Why this happens

Odometry multiplies counted ticks by a distance per tick, so every constant in that calculation is repeated on every metre travelled. The distance per tick is the wheel circumference divided by the ticks for one wheel turn. If the diameter is wrong by 1 percent, the distance is wrong by 1 percent forever. Turns work the same way: the heading change is the difference between the two wheel travels divided by the distance between the wheels, so an error in that distance scales every turn.

Some error cannot be calibrated. Wheel slip, tyre squash, uneven floors and sampling at a low rate add random drift. Calibration removes the systematic part, and a gyro or another reference handles the rest.

## How to confirm the cause

- Measure the wheel diameter with a caliper at several points, then roll the robot by hand over a known distance and compare with the count.
- Count ticks for exactly one wheel turn by hand several times and average. This also checks the encoder and gearbox ratio.
- Drive straight for a long distance, such as 2 m, and measure the real distance with a tape. Repeat in both directions.
- Turn in place for ten full turns and mark the start heading. Measure how far it ends from the mark.
- Compare left and right distances on a straight run. A difference points to unequal wheel diameter or unequal tick counts.

## Worked example

Working through a calibration. The wheel is 65 mm and the encoder gives 360 ticks per wheel turn:

```
const float WHEEL_MM = 65.0, TICKS = 360.0;
const float MM_PER_TICK = PI * WHEEL_MM / TICKS;  // 0.5672

// 2000 mm should give 2000 / 0.5672 = 3526 ticks.
// Robot reports 1980 mm for a true 2000 mm:
//   scale = 2000 / 1980 = 1.0101
//   effective wheel = 65.0 x 1.0101 = 65.66 mm
// Turn test: odometry says 10 turns, tape says 9.6 turns:
//   new track = old track x 10 / 9.6   (150 -> 156.25 mm)
```

## Common mistakes

- Changing wheel diameter to fix a track-width error, or the reverse.
- Calibrating on a smooth table and running on carpet.
- Counting ticks with an interrupt that misses pulses at high speed.
- Using too short a test run, so measurement error is larger than the drift.
- Calibrating with an empty battery tray and running with a full one; load changes the squash of soft tyres.

## If this did not fix it

- Missed encoder pulses caused by a slow loop or a noisy signal.
- Wheel slip from too-fast acceleration; add a ramp.
- A gyro or heading source that is not calibrated, which spoils the corrections you add.
