Troubleshooting · SLAM and localization
SLAM fails in repetitive environments
When every place looks the same the matcher has nothing to hold on to, or holds on to the wrong place.
1. Symptoms
- The map stretches or shortens along a corridor.
- Loop closure joins two different aisles.
- The robot localises to the wrong aisle after a restart.
2. Possible causes
- Scan matching is under-constrained along a featureless direction.
- Loop closure accepts a match between similar places.
- Odometry is the only constraint along the corridor.
- Visual place recognition confuses repeated patterns.
3. Measurements to collect
- Scan-match response or covariance along the corridor.
- Loop-closure candidates and their scores.
- Odometry error over the corridor length.
4. Diagnostic commands
Commands are not executed by the site’s automated tests (they need a ROS 2 Jazzy installation or the robot).
ros2 topic echo /slam_toolbox/graph_visualization --once
ros2 bag record /scan /odom /tf5. Step-by-step investigation
- Find the direction without constraint (along the corridor).
- Add a constraint there: wheel and IMU odometry, a feature at the ends, markers.
- Tighten loop acceptance (higher match response, smaller search distance) or require a consistency check.
- Add global cues (a map, markers or GNSS) to disambiguate.
- Test restart localisation from several start places.
6. Corrective actions
- Improve odometry and fuse the IMU.
- Add reflectors, fiducial markers or a known landmark.
- Raise loop-closure thresholds and add geometric verification.
- Use an initial pose from a known dock.
7. Validation after the fix
- Corridor length in the map matches the measured length within the requirement.
- No false loop closures in repeated runs.
References
- slam_toolbox loop-closure parameters: example configuration, read 2026-11-06.