With no GPS indoors, a robot can still keep track of itself by adding up its own small moves. This is odometry, or dead reckoning.
Key idea
Each loop, the encoders give a distance $d$ and a turn $\Delta\theta$. Update the pose: $x \leftarrow x + d\cos\theta$, $y \leftarrow y + d\sin\theta$, then $\theta \leftarrow \theta + \Delta\theta$. Small loops make this simple rule accurate.
Why it works
Each step is a tiny straight move along the current heading, which is the coordinate-frames rule with the robot's own forward direction. But every step's small error is kept forever: slipping wheels, a slightly wrong wheel size. So odometry drifts, and the error grows the farther the robot goes.
Worked example: One step
Pose $(1.0, 2.0)$, heading $60^\circ$, move $0.5$ m.
- $x = 1 + 0.5\cos 60^\circ = 1.25$.
- $y = 2 + 0.5\sin 60^\circ \approx 2.43$.
Answer: (1.25, 2.43).
Common mistake
Updating the heading before moving when the rule says move first, or forgetting that small errors grow with every meter.
Hands-on: drive a square
Program your robot to drive a 1-meter square using encoder odometry, and mark where it ends. Repeat five times. The gap between start and finish shows your odometry's drift. Try slower turns, or measuring your wheel size more carefully, and see what helps.