Odometry drifts. A map needs to know where the robot is; knowing where the robot is needs a map. Doing both at once is called SLAM: simultaneous localization and mapping.
Key idea
A heading error $\theta$ pushes the robot sideways by about $d\sin\theta$ after $d$ meters, so errors grow with distance. Seeing a landmark again, whose place is already on the map, pulls the estimate back. Recognizing a place seen before and fixing the whole map is called loop closure.
Why it works
SLAM methods are built from the pieces in this ladder: odometry predicts, sensors measure, and a filter like the Kalman filter blends the two, now for the robot's pose and the landmarks' places together. Modern robot vacuums with lidar or cameras use SLAM to clean in neat rows.
Worked example: Sideways error
A 2° heading error over 10 m.
- $10 \sin 2^\circ \approx 10 \times 0.035 = 0.35\ \text{m}$.
Answer: About 35 cm.
Common mistake
Thinking a small heading error stays small. Its effect grows with every meter driven.
This topic gives the ideas only. A full treatment needs probability through Bayes' rule and the multivariable Kalman filter; Probabilistic Robotics by Thrun, Burgard and Fox is the standard text.