Scan 3D maps with FAST-LIO2
Three terminals: simulation, SLAM, driving. Drive the robot around the platform and then return to the starting point, the 3D map grows larger in RViz with each segment.
Map after a 52 m round: floor, two slopes, platform surface, boundary wall, barrel and column. The trajectory ends exactly where it started.
World ramp
World is small, with few objects, so SLAM runs lightly and quickly. Platforms and ramps make the robot actually go up and down, so the map is 3D rather than flat.
1. Simulation
Terminal 1
ros2 launch atlas3d_bringup bringup.launch.py world:=ramp.sdf wheel_odom_tf:=false rviz:=false
wheel_odom_tf:=false: turn off TF of wheel odometry. When running SLAM, FAST-LIO2 is the place to broadcast the robot position; If two sources transmit the same TF edge, RViz and Nav2 receive position jumping back and forth. M02 explains the TF tree.rviz:=false: SLAM automatically opens RViz separately in the following step.- Add
headless:=trueif the device is weak. The simulation still runs fine, just doesn't draw the Gazebo window.
Wait for line Configured and activated diff_drive_controller (dev machine: 5 s).
2. SLAM
Terminal 2
ros2 launch atlas3d_slam fastlio2.launch.py
One command runs both parts: FAST-LIO2 pairs each LiDAR scan with the IMU to know where the robot is and builds a map, PGO selects locations about 0.5 m apart as keyframes, finds where the robot returns to the old area to adjust the map to match. Log must have:
[pgo.pgo_node]: Optimized map publisher: /atlas3d_map (every 2 seconds)
Let the robot stand still for a few seconds for FAST-LIO2 to sample the IMU while standing still, wait for RViz to scan before driving.
RViz by SLAM
| Display | Topic | |
|---|---|---|
| 3D Map | /atlas3d_map | Composite map from all keyframes, updated every 2 s |
| Scan now Latest | /fastlio2/world_cloud | Scan, placed in frame map |
| trajectory FAST-LIO | /fastlio2/lio_path | The robot path followed FAST-LIO2 |
| trajectory PGO (optimized) | /pgo/optimized_path | Line connecting keyframes after PGO straightening |
| Camera RGB | /camera/color/image_raw | Front camera photo |
Fixed Frame is map: the origin is where the robot stands when SLAM is turned on, the x axis is in the direction of the robot's nose at that time. Therefore, the coordinates on the map are different from the coordinates in the Gazebo (lesson 2 uses this again).
3. Drive around
Terminal 3
ros2 run teleop_twist_keyboard teleop_twist_keyboard
Route as shown in the scene at the beginning of the article:
- Go straight north for about 3 m, turn widely left (west) then turn right to enter west slope straight east. The slope is 2 m wide, the robot is 0.56 m wide: if you go wrong, the wheel will easily slide off the edge.
- Go uphill, walk along the platform, downhill east.
- Turn south, go along the row of columns and crates, and return to the starting point.
Keep the default teleop speed (0.5 m/s, 1.0 rad/s), slow motion. Spinning quickly on the spot causes blurry scans, which is the most common cause of skewed maps.
Check before saving
- The platform surface and two slopes are seamless, with no overlapping floor layers
- The wall is straight, not forming two parallel lines
- trajectory PGO closes at the starting point
- Can see both the north and south sides of the platform (lesson 4 explains why it is necessary)
Measurements on dev machine
The above route is driven automatically by the repo's test script, comparing the SLAM position with the ground truth taken from Gazebo:
| Quantity | Value |
|---|---|
| Distance / time | 52.5 m / 90 s |
| Keyframe | 107 |
| Position error compared to true (ATE, root mean square) | 1.1 cm, largest 4.7 cm |
| CPU processes (100 % = 1 thread) | Gazebo 91 %, FAST-LIO2 39 %, bridge + IMU filter 27 %, PGO 5 %, remaining 9 % |
| RAM processes | 1.2 GB (Gazebo 0.7 GB) |
1 cm error over 52 m is due to clean simulation: no vibrations, no moving objects. The real robot's error is many times larger. M06 instructs how to measure this error using ground truth.
Common errors
wheel_odom_tf:=false so only SLAM publishes frame odom.