FixTheRobot Explore Robotics / Systems Engineering / Engineering Guides / Module 09

Engineering Guides · Module 09

Diagnosing drift and tracking loss

Measure drift first. A number lets you tell a bad parameter from a bad sensor.

  • Intermediate
  • Module 09: SLAM Selection, Configuration & Troubleshooting
  • Written for ROS 2 Jazzy where ROS 2 is used
  • Sources checked 2026-11-06

Assumptions: Numbers in the examples are illustrative and the code is executed by the site’s tests. Facts taken from a cited source are marked; other statements are general engineering knowledge and must be confirmed on the datasheet of the part you use.

1. Engineering problem

SLAM error grows with distance travelled unless something corrects it. A robot that drifts is either missing a constraint (loop closure, a second sensor) or feeding the estimator wrong data (time offsets, bad calibration, slip).

2. When is this needed?

  • Maps are bent or do not close.
  • A visual or LiDAR tracker reports lost tracking.
  • After changing a sensor, mount or parameter.

3. Selection and design decisions

A simple, repeatable measure: drive a loop that returns to the start with no loop closure active and report the gap between the start and the final estimated position as a percentage of the path length. Keep the route, speed and environment fixed so results compare.

Overview
CauseEvidenceFix
Wheel slip, bad odometryDrift grows on smooth floors or turnsFuse IMU, improve odometry model
Time offset or wrong extrinsicError appears while turning or moving fastCalibrate (see the calibration guides)
Low featuresTracking lost in plain areasAdd a modality or illumination
Over-aggressive thresholdsScans dropped or too fewAdjust travel thresholds
No loop closureGap at the end of every loopEnable and tune loop closure
Dynamic objectsMap ghosts and jumpsFilter dynamic points, use more static structure

4. Advantages and disadvantages

  • Aggressive loop closure removes drift and can warp the map on false matches.
  • More sensors reduce drift and add integration.
  • Slower motion reduces blur and drift and costs mission time.

5. Requirements and constraints

  • Drift measured on a fixed route and recorded.
  • Changes made one at a time.
  • Tracking-loss events logged with place and time.

6. Architecture

run loop ─▶ measure gap and path length ─▶ drift % ─▶ change one thing ─▶ repeat

7. Implementation

  1. Record a loop run with the sensors and the estimator’s output.
  2. Compute drift as gap ÷ path length (below).
  3. Find where the error grows: straights, turns, specific places.
  4. Check calibration, time offset, features, thresholds in that order.
  5. Repeat the measurement after each change.
import math
path = [(0, 0), (10, 0), (10, 10), (0, 10), (0.4, 0.3)]     # estimated trajectory of a loop that should end at the start
length = sum(math.dist(a, b) for a, b in zip(path, path[1:]))
err = math.dist(path[0], path[-1])
print(f"path length {length:.1f} m, loop-closure gap {err:.2f} m, drift {err / length * 100:.2f} % of distance travelled")

Printed (checked by the site’s tests):

path length 39.7 m, loop-closure gap 0.50 m, drift 1.26 % of distance travelled

Reading it: the 40 m loop ends 0.50 m from its start, which is 1.26 % of the distance travelled. Whether that is acceptable depends on the requirement; the value is illustrative.

8. Real examples

  • Corridor loop: 1 % drift without loop closure, corrected to a small gap with loop closure enabled.

9. Failure scenarios

  • Changing three parameters and not knowing which helped.
  • Measuring on a different route each time.
  • Ignoring the places where tracking was lost.

10. Troubleshooting

  1. Plot the trajectory against a reference if you have one.
  2. Mark tracking-loss events on the map.
  3. Compare still and moving behaviour.

11. Validation

  • The calculation prints the line shown (executed by the site tests).
  • Drift on the reference route is below the requirement after the fix.

12. Engineering checklist

13. Further references

Related on FixTheRobot