Atlas Robotics
SLAMIntermediate

slam_toolbox: flexible SLAM in the ROS2 ecosystem

Atlasbot · 17/8/2026 · 11 min read

slam_toolbox: flexible SLAM in the ROS2 ecosystem
Three modes of operation of slam_toolbox

The article SLAM is what? presented a generic Front-end/Back-end framework. slam_toolbox— package developed by the ROS2 community (Steve Macenski) — realizes that framework with a notable strength: not only new map construction, but also flexible reloading, forward mapping, and localization on the old map.

Key concepts

slam_toolbox has 3 modes of operation, serving 3 different stages in the map life cycle:

  • Online— real-time map generation while robot is moving
  • Offline— reloads the recorded data for the following mapping
  • Lifelong mapping — load existing map, continue to build/update instead of starting from scratch

There is also Localization mode— localization on the saved static map, which serves as an alternative to AMCL.

How it works

Online (live mapping)
  → builds the map in real time while the robot moves
  → the most common mode, used when scanning a new area for the first time

Offline (post-processing)
  → loads recorded data (ros2 bag, covered separately) to build a map
  → useful for trying several parameter sets on the same physical scan

Lifelong mapping
  → loads an EXISTING map and extends/updates it instead of starting over
  → changes such as new shelves do not require rescanning the entire area from zero

Mode lifelong mapping is the biggest difference from many other SLAM systems — which mostly only support new mapping from scratch, with no way to "update" the old map without losing existing data. The underlying mechanism is that slam_toolbox saves pose-graph (.posegraph)— the entire constraint structure between the estimated poses, not only the final result as an image as file .pgm/.yaml (net occupation grid, article Map). This pose-graph reload allows the optimization/map expansion to continue exactly as the state was stopped.

About Localization mode: slam_toolbox has a localization mode on the saved FIX map, which is identical to the role of AMCL, but still uses the same pose-graph optimization engine of SLAM. This is an alternative to AMCL (the article AMCL in Nav2) — which also solves the existing map-based localization problem, but by pose-graph optimization instead of particle filter, in exchange for losing some of the particle filter's own characteristics (such as the ability to handle the multiple positional hypotheses situation — stated in the article What is AMCL?).

**In summary:**slam_toolbox is not only a "SLAM algorithm" — it is a versatile toolkit for all three stages of the map life cycle: online construction, offline processing, continuous updating, and also localization after map (localization mode) — a package that replaces both map_server and part of the role of AMCL.

Technical details

Formulas

The cost of lifelong mapping compared to reconstruction from scratch — benefits increase with variable area ratio relative to total map area:

Lifelong_cost ≈ f(changed_area)
Rebuild_from_scratch_cost ≈ f(entire_area)

Example: 1000m² warehouse, only 50m² changes (new shelves, 5% of the total area)
→ lifelong mapping only needs to rescan ~50m², saving ~95% of the time/effort
compared with rescanning the whole 1000m² from scratch

Parameters

ModeInputResult
OnlineReal-time Sensor Datanew map, built directly
Offlineros2 bag specifiednew map, built from old data, can test multiple parameters
Lifelong mappingmap + pose-graph already existsmap update, keep unchanged section
Localization modestatic map already existsEstimating position (instead of AMCL)

Practical applications

In real-world warehouse operations, non-permanent layout — shelving is added/subtracted/moved according to business needs. With SLAM supporting only de novo construction from scratch, each layout change required a time - consuming — scan of the entire region and the robot's operation had to be stopped during the scan. slam_toolbox's lifetime mapping mode correctly solves this problem: simply allowing the robot to traverse the changed area, the remaining map remains the same as it was — greatly reducing the operating cost compared to scanning back from scratch each time the layout changes.

Practical example

# Online Mode — real-time New Map
ros2 launch slam_toolbox online_async_launch.py

# Lifetime mapping mode — loads old map, keeps updating
ros2 launch slam_toolbox online_async_launch.py \
  slam_params_file:=lifelong_params.yaml

# Localization Mode — localization on static map, replacing AMCL
ros2 launch slam_toolbox localization_launch.py \
  map_file_name:=my_map

The above three commands properly illustrate 3 different roles of the same package — other than having to install and configuration separately map_server+AMCL+ another SLAM for the 3 respective needs.

Common mistakes

  • Select slam_toolbox and still use separate AMCL without taking advantage of Localization mode — which misses the benefit of reducing the number of dependencies to manage, although technically not wrong.
  • Resetting the map from scratch whenever the layout changes small — as in the Example section, does not take advantage of a lifetime mapping that consumes unnecessary time/power for the constant map section.
  • Communication between Offline (reprocessing from bag) and Lifelong mapping (update old map) — two modes that address two different needs, using the wrong mode leads to unexpected results.
  • No pose-graph save save only map.pgm — lose the ability to continue map expansion/update by lifelong mapping later, reconstructing from the beginning if only image file is available.

Conclusion

slam_toolbox stands out not only for its map quality but also for its flexibility over the entire map life cycle — to rebuild, re-process, update, and also localize after the map is available, all in one package. This is a good option if you need a fast - growing loop and a changing environment over time. The next article in the column goes to Cartographer — selecting the most popular remaining SLAM in ROS2, with a distinctly different internal architecture.

Get new articles and lessons by email

When a new technical article or course module is published, Atlas Robotics sends you a short email. No spam.

Unsubscribe any time with the link in each email. See our Privacy policy.

slam_toolbox: flexible SLAM in the ROS2 ecosystem — Atlas Robotics