Skip to content

Conversation

@matlabbe
Copy link
Member

@matlabbe matlabbe commented Jan 25, 2026

This PR adds a new way to automatically merge sessions when we switch from mapping mode to localization mode online. Related to #1635

Original behavior:

  • We created a first map with the robot, then we switched to localization mode to do navigation without increasing the size of the map over time.
  • However, if we want to extend the map afterwards, switching to mapping mode while the robot was localizing in the map would create a new mapping session. RTAB-Map will then flush the previous optimized graph and start a new one. If the robot is able to do a visual loop closure, the old map will re-appear linked to the new session. That generally works when a camera is used and if there are enough discriminating visual features shared between the old map and the new session.

Problem:

  • This currently not works with lidar-only setup
  • This limits the usage of proximity detection, that could also help visual re-localization, assuming we were already localized in the map

Solution:

  • The idea is to not flush the current optimization graph when we switch to mapping mode
  • Keep the odometry cache constraints
  • Support RGBD/ProximityMaxGraphDepth parameter

Results:

  • When we switch from localization mode to mapping mode, if there was a loop closure / proximity detection between the odometry cache (see RGBD/MaxOdomCacheSize) and the map, proximity detection can be done between the new map nodes towards to "closest" nodes in the previous map based on RGBD/ProximityMaxGraphDepth and the constraints in odometry cache.
  • If there is no recent loop closure / proximity detection in odometry cache, the new session will be disjoint from the old maps, thus proximity detection won't be possible, except if RGBD/ProximityMaxGraphDepth is disabled (set to 0).
  • Note that if the new map is optimized before closing a loop with the old map, and the odometry cache doesn't have any loop closures, the old map will disappear. The only way at that point to merge with the old map is to find a visual loop closure (like the original behavior).

Here a sequence of switching between mapping and localization modes using only lidar-based mapping (no visual loop closures possible), showing that as long as the robot is already localized in the map, it can now find proximity detections with the old map when switching from localization to mapping modes.

Peek.2026-01-24.17-24.mp4

Here is a case when we switch to mapping mode while the robot cannot localize in the previous map, it depletes the odometry cache and optimizes its own map before localizing in the old one. In this case, without a camera, we cannot automatically merge the new session with the old one, one would have to do it manually with rtabmap-databaseViewer.

Peek.2026-01-24.17-26.mp4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants