Lesson 19 of 2255 minutes

Odometry, Drift, and State Estimation

Start with the lesson question, connect the representations, and test the model with evidence.

odometrydriftlocalizationstate estimationcovariance

Learning objectives

  • Explain odometry, drift, landmarks, and state estimation.
  • Interpret an occupancy map and the purpose of SLAM.
  • Diagnose failures across localization, planning, and control.
Lesson flowHook, model, explanationShow guidance

Inspect the opening phenomenon

Predict what changes, then name the evidence.

Apply in the lab

Name the evidence before reading the answer.

Read only what helps

Then use the lab and recall check.

More when needed

Transcript and resources stay available below.

Course progress

AI & Robotics Foundations · Localization, Mapping, and Navigation · Lesson 19

Odometry, Drift, and State Estimation

In progress

Decision challenge

Observe the phenomenon. Then connect the representations.

Use the opening example to make a prediction, identify evidence, and explain which model supports it.

Why Does Robot Odometry Drift? State Estimation Explained

Predict motion, compare independent evidence, and correct according to uncertainty.

Predict motion, compare independent evidence, and correct according to uncertainty.

Reference drawerTranscript, source notes, scripts, and package status stay tucked away until you need them.6 files

Lesson reading

live

55 min

Video script

draft

Transcript fallback

available

courses/ai-robotics/modules/07-localization-mapping-and-navigation/lessons/01-odometry-drift-and-state-estimation/video-transcript.md

Watch Drift Grow, Then Correct It

published

30 min

Mastery check

live

5 questions / 10 min

Transcript for accessibility and fallback

# Transcript A robot returns to its starting point, but odometry says it missed. Why? Odometry adds small motion estimates over time. It also adds wheel slip, scale error, and floor irregularities. Here, a tiny right-wheel bias bends the estimated path away from the true path. The estimator predicts from motion, compares that prediction with independent landmark evidence, then corrects the state according to uncertainty. The continuous odom frame is useful for control, even though it drifts. The map frame provides global correction and may jump. Predict, compare, correct—and always check time, frame, validity, and covariance. Which frame should a local controller follow? Practice the full drift-and-correction lab on EduQuest. ## V3 concise narration This robot returned to its starting point. But its odometry says it missed. How can both be true? Odometry adds thousands of tiny wheel rotations to estimate x, y, and heading. A little wheel slip looks harmless once. Integrated again and again, it bends the estimated path away from reality. A timestamped landmark gives independent evidence. The estimator predicts, compares, then corrects according to uncertainty. Quick check: which frame should stay smooth for local control—map or odom? Test your answer on EduQuest.

Reading lab

Core explanation

Connect the lesson's words, diagrams, graphs, evidence, and equations.

Why can a robot return to its starting point while its map says it missed?

Odometry estimates motion relative to a starting pose. Every wheel rotation, visual feature match, or inertial update is slightly uncertain. Integrating those increments also integrates their errors, so the estimated path can gradually separate from the true path. State estimation manages that uncertainty by predicting motion, comparing the prediction with independent observations, and correcting the estimate.

Wheeled robot in a robotics laboratory visualizing true path, estimated path, lidar sweeps, and landmark correction

Learning objectives

  • Explain how planar wheel odometry updates position and heading.
  • Distinguish short-term continuity in odom from globally corrected pose in map.
  • Diagnose slip, scale error, timing error, and weak landmarks as sources of drift.
  • Interpret covariance as uncertainty, not guaranteed error bounds.
  • Apply the predict–observe–correct loop to a localization trace.

Mental model: a pencil line with an eraser

Motion evidence draws a continuous pencil line. The robot predicts its next state from the previous state and the measured motion. A landmark observation is an eraser and ruler: it does not replace the whole drawing, but it can pull the estimate toward a pose supported by external evidence.

For a differential-drive robot with left and right wheel increments ΔsL and ΔsR, wheel separation b, and current heading θ:

Δs = (ΔsR + ΔsL) / 2

Δθ = (ΔsR - ΔsL) / b

x' = x + Δs cos(θ + Δθ/2)

y' = y + Δs sin(θ + Δθ/2)

θ' = θ + Δθ

The midpoint heading reduces curvature error for a small step, but it cannot remove incorrect wheel increments.

Worked example

A robot has wheel separation b = 0.40 m. In one update the left wheel reports 0.20 m and the right wheel reports 0.24 m.

  • Forward increment: (0.24 + 0.20)/2 = 0.22 m
  • Heading increment: (0.24 - 0.20)/0.40 = 0.10 rad, about 5.7°

If the right wheel slipped and actually traveled only 0.21 m, the update invents both extra forward motion and extra rotation. Repeating small biased updates makes the path drift.

Continuous pose and global correction

ROS REP 105 separates three useful frames:

FrameMeaningDesired behavior
base_linkRobot-fixed body frameMoves with the robot
odomLocally consistent world frameContinuous, accurate over short intervals, allowed to drift
mapGlobally referenced world frameLong-term accurate, allowed to jump when localization corrects

The typical chain is map → odom → base_link. Keeping local continuity separate from global correction prevents a sudden landmark update from looking like an impossible jump in wheel motion.

Predict, observe, correct

  1. Predict: apply the motion model and increase uncertainty.
  2. Observe: transform a timestamped landmark, scan, or other measurement into a comparable frame.
  3. Compare: compute the innovation—the difference between predicted and observed evidence.
  4. Correct: combine evidence according to uncertainty; do not blindly snap to either input.
  5. Check: monitor residuals, covariance, timing, frame IDs, and rejected measurements.

The nav_msgs/Odometry message carries pose and twist with covariance. Covariance expresses the estimator's uncertainty model. A small covariance does not prove correctness; an overconfident wrong sensor can damage fusion.

Misconception checks

  • “Encoder counts are ground truth.” They measure shaft rotation, not guaranteed motion across the floor.
  • “An EKF removes drift.” A filter cannot create missing information. Without independent absolute evidence, uncertainty and drift remain.
  • “More sensors always improve localization.” Correlated, stale, misframed, or overconfident data can make the estimate worse.
  • “A correction means odometry failed.” Continuous local odometry and discontinuous global correction serve different navigation needs.

Retrieval pause

A robot drives straight, but one wheel radius is configured 2% too large. Predict the shape of the odometry error. Which observation could correct it, and what must match before fusion?

Summary

Odometry integrates relative motion and therefore accumulates error. A useful estimator preserves short-term continuity, represents uncertainty, and uses independent, correctly timed and framed observations to correct long-term drift. Diagnose localization by checking motion assumptions, timestamps, frames, covariance, and innovation—not only the final path.

Further learning

Practice labWatch Drift Grow, Then Correct ItOpen this when you are ready to apply the model, collect evidence, and check your explanation.30 min

Lab: Watch Drift Grow, Then Correct It

Objective

Use a spreadsheet or short script to integrate wheel odometry, inject a realistic error, and apply landmark corrections. No robot hardware or paid software is required.

Materials

  • Spreadsheet software or a short local script
  • The equations in the lesson
  • Optional graphing tool; a numeric comparison is an accessible fallback

Setup

Create columns for step, left increment, right increment, estimated x, estimated y, estimated heading, landmark x/y, corrected x/y, and uncertainty score. Use wheel separation b = 0.40 m and start at (0,0,0).

Steps

  1. Enter 20 straight steps where both wheels travel 0.20 m.
  2. From step 6 onward, multiply the reported right-wheel increment by 1.02 to simulate radius miscalibration.
  3. Integrate the equations from the lesson using the midpoint heading.
  4. At steps 10 and 20, add a landmark observation of the true pose with uncertainty 0.04 m².
  5. Use a simple correction corrected = 0.25 × predicted + 0.75 × observed for position. Label this as a teaching approximation, not a full Kalman filter.
  6. Plot true, odometry-only, and corrected paths. Plot uncertainty increasing each prediction step and decreasing after accepted landmarks.
  7. Repeat with a stale landmark shifted back two steps. Decide whether to reject it or transform it using measurement time.

Expected Result

  • Odometry-only pose curves gradually because the wheel-scale bias creates a false heading change.
  • Landmark corrections reduce global position error but may introduce discrete changes.
  • A stale observation can make the estimate worse even when the landmark position itself is accurate.

Troubleshooting

  • If the path turns the wrong direction, check the sign convention for ΔsR - ΔsL.
  • If heading is in degrees, convert to radians before sin and cos.
  • If correction jumps are huge, confirm both positions use the same frame and timestamp.
  • If uncertainty never changes, explicitly add process uncertainty during prediction and reduce it only when valid external evidence is accepted.

Accessibility fallback

Learners who cannot use a chart can compare the numeric lateral error at steps 5, 10, 15, and 20 and describe its trend. The transcript and annotated visual convey the same mechanism without relying on motion or color.

Reflection Questions

  1. Which error source caused systematic curvature?
  2. Why does a landmark help only when time and frame are correct?
  3. Why should odom remain continuous even when map is corrected?
  4. What evidence would justify rejecting a landmark update?

Extension Challenge

Run the same trace with unbiased wheels but a landmark observation delayed by two steps. Compare rejection, naive fusion, and acquisition-time transformation. Explain which result is defensible and why.