localization robot on saved map
Reopen the simulation, loading the old map instead of building a new one. Localizer compares the current LiDAR scan with the map to find where the robot is, then holds that position while the robot moves.
[atlas3d_relocalize]: ICP alignment accepted. Kiểm tra scan trùng map trong RViz trước khi lái.
In RViz, the current scan fits onto the walls, crates, and platform edges of the saved map.
Run
Reopen simulation with world so that the robot returns to the correct starting place (also keyframe 0 in poses.txt).
Terminal 1
ros2 launch atlas3d_bringup bringup.launch.py world:=ramp.sdf wheel_odom_tf:=false rviz:=false
Terminal 2
MAP_DIR="$HOME/atlas_sim3D/src/atlas3d_mapPCDs/ramp/run_01"
ros2 launch atlas3d_slam fastlio2.launch.py mode:=localization \
map_path:="$MAP_DIR/map.pcd" pose_file:="$MAP_DIR/poses.txt" pose_index:=0
Log on dev machine, time from typing command:
| After | Log line | Meaning |
|---|---|---|
| 0.4 s | Đọc 1285934 điểm map trong 0.1 s | Loaded map.pcd |
| 0.4 s | Gửi pose (poses.txt dòng 0): x=-0.00 y=-0.00 … | Initial guess position taken from keyframe 0 |
| 4.2 s | Khởi tạo khớp map (dò 1555 ms): x=-0.00 y=-0.01 z=-0.01 | The best match has been found |
| 5.0 s | ICP alignment accepted | Position accepted, start publishing TF map → odom |
Hold the robot still until the last line is reached. Previously, RViz reported that Message Filter dropping message: frame 'odom' was normal: there was no TF from map.
When the robot is not standing at the starting point
Localizer only searches around the predicted location, within ±1 m and ±30°. If the robot is somewhere else, you must show it the approximate location using RViz:
- Click the 2D Pose Estimate button on the RViz toolbar.
- Click on where the robot is standing on the map, hold the mouse and drag in the direction of the robot's nose, then release.
- Wait
ICP alignment accepted.
Test on dev machine: robot stands at the starting point, intentionally clicking 0.86 m and 20°. Localizer probes for 1.6 s, returns (0.00, −0.01), right where the robot stands; whole process 2.1 s after clicking.
RViz only gives x, y and direction. The height is taken from the floor surface in the map below the click point, the tilt angle is taken from the IMU, so if you click on the platform surface, the localizer will automatically set the robot at a height of 0.6 m.
Try it yourself
- Click 2D Pose Estimate is about half a meter away from the robot: scan jumps to match the map
- Drive the robot onto the platform using teleop: the scan stays consistent all the way
- Call the check service below, receive
valid: true
Check status from another terminal:
ros2 service call /localizer/relocalize_check interface/srv/IsValid '{code: 0}'
valid: true means the last match was accepted and the data is fresh.
Common errors
terrain.sdf (default). Add world:=ramp.sdf.