Engineering Guides · Module 09
Diagnosing drift and tracking loss
Measure drift first. A number lets you tell a bad parameter from a bad sensor.
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.
| Cause | Evidence | Fix |
|---|---|---|
| Wheel slip, bad odometry | Drift grows on smooth floors or turns | Fuse IMU, improve odometry model |
| Time offset or wrong extrinsic | Error appears while turning or moving fast | Calibrate (see the calibration guides) |
| Low features | Tracking lost in plain areas | Add a modality or illumination |
| Over-aggressive thresholds | Scans dropped or too few | Adjust travel thresholds |
| No loop closure | Gap at the end of every loop | Enable and tune loop closure |
| Dynamic objects | Map ghosts and jumps | Filter 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 ─▶ repeat7. Implementation
- Record a loop run with the sensors and the estimator’s output.
- Compute drift as gap ÷ path length (below).
- Find where the error grows: straights, turns, specific places.
- Check calibration, time offset, features, thresholds in that order.
- 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 travelledReading 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
- Plot the trajectory against a reference if you have one.
- Mark tracking-loss events on the map.
- 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
- READMEs of the projects, read 2026-11-06: slam_toolbox, ORB-SLAM3, LIO-SAM, FAST-LIO, VINS-Fusion.