MyRoboPath
autonomous slam16 min readUpdated 2026-03-07Intermediate

2D LiDAR SLAM with SLAM Toolbox & Google Cartographer in ROS 2

Step-by-step tutorial comparing SLAM Toolbox vs Cartographer: tuning scan matchers, configuring submaps, running lifelong multi-session mapping, and saving .yaml/.pgm occupancy grids.

Dr. Liam Sterling
Dr. Liam Sterling
Head of Autonomous Navigation

Key Engineering Takeaways

  • SLAM Toolbox is the official default SLAM system in ROS 2 Nav2, featuring built-in lifelong mapping and map merging.
  • Cartographer excels at multi-sensor fusion (2D LiDAR + IMU + Odometry) using continuous-time 2D submaps.
  • Save final maps using `ros2 run nav2_map_server map_saver_cli -f my_warehouse_map`.
Prerequisites
  • ROS 2 Humble
  • LaserScan topic

SLAM Toolbox vs Google Cartographer Comparison

| Feature | SLAM Toolbox (Karto-based) | Google Cartographer | | :--- | :--- | :--- | | **ROS 2 Integration** | Native First-Class (Steve Macenski) | Ported from ROS 1 | | **Lifelong / Continuous Mapping** | Yes (Add / remove map features dynamically) | Experimental | | **Multi-Session Map Merging** | Built-in via RViz plugin | Requires manual pbstream merging | | **Submap Scan Matching** | Karto Scan-to-Scan Matcher | Ceres Non-Linear Optimizer |
Tags:#SLAM Toolbox#Cartographer#2D SLAM#LiDAR#Occupancy Grid#ROS 2