BUILD A MAP
Drive the car slowly around a room and turns the LiDAR sweeps and wheel odometry into a 2D occupancy grid. Three backends ship on the car: pick one, watch the map form in , then save it for navigation.
WHAT HAS TO BE RUNNING
Mapping is an activity, not a service. It runs in the foreground on top of two things that have to be up first, and racecar mapping warns you if either is missing.
- The driver. It publishes
/scanand/odom, which is what SLAM consumes. It starts at boot, so this is usually already true. Leave it running; do not stop the services. - The autonomy base. The transform tree comes from here. It is not a service yet, so start it in a terminal of its own and leave it there. See File system.
- A bounded indoor space with walls the LiDAR can see. Glass and mirrors read as gaps, so keep them out of the run.
- The transmitter in your hands, SWB up (manual). You drive; SLAM only watches.
bash# terminal 1: the autonomy base. Leave this running. bash ~/ros2_ws/src/neoracer_ros2_driver/scripts/launch_autonomy.sh
START MAPPING
One command, in a second terminal. It runs in the foreground until you Ctrl-C it. With no backend named you get slam_toolbox.
bash# terminal 2: the mapper. Ctrl-C when the map is complete. racecar mapping # slam_toolbox, the default racecar mapping gmapping racecar mapping cartographer
| Backend | Good for |
|---|---|
| slam_toolbox | The default. Solid pose-graph SLAM, easy to resume and refine. |
| gmapping | Classic particle-filter SLAM. Light and familiar. |
| cartographer | Loop-closure heavy, good on larger or repetitive spaces. |
WATCH IT IN RVIZ
A third terminal opens the vendor's pre-configured mapping view, fixed frame already set to map. As you drive, the occupancy grid fills in around the car.
bash# terminal 3: the view racecar mapping rviz racecar mapping rviz cartographer # Cartographer has its own debug view
The grid
The scan
The path
SAVE THE MAP
With the mapper still running and the space covered, save from another terminal. The same command works whichever backend you used. Name the map and that name is what you drive later.
bashracecar mapping save lab # -> lab.pgm + lab.yaml racecar mapping save # no name given: saves as "map"
You get an image and a metadata file in the vendor workspace, at ~/osracer_ws/src/osracer/osracer_slam/maps/. That pair is what Nav2 loads, and the save prints the exact command to drive it.

