Skip to content

Reduce graph: added option to remove orphan nodes from WM after reduction - #1735

Merged
matlabbe merged 20 commits into
masterfrom
reduce_graph_orphan_nodes
Jul 29, 2026
Merged

matlabbe merged 20 commits into
masterfrom
reduce_graph_orphan_nodes

Conversation

@matlabbe

@matlabbe matlabbe commented Jul 10, 2026 •

Copy link
Copy Markdown
Member

The issue is that the current graph reduction may split the graph and some nodes may get disconnected from the optimized graph. A new option called --remove_orphan_nodes can trigger a cleanup of the working memory and long-term memory by deleting those nodes from the global optimized graph. This is only done when all nodes from WM and LTM are contained in the global graph. To trigger it even if not all nodes were reviously in the global graph, we can do --remove_all_orphan_nodes at your own peril.

Example of a case where it matters:

  • We mapped an environment (in one or multiple sessions) and we change back in localization mode for autonomous navigation, without having the map changing. We also assume that the global optimized graph includes all nodes from WM and LTM. If we reduce the size of the map with rtabmap-reduceGraph tool, it is possible that one or more nodes get disconnected from the global graph. The global graph may then be smaller than number of nodes in WM and LTM. The robot can still localize on nodes that are not connected to that graph but still in WM, which would trigger a re-optimization of the full graph. With --remove_orphan_nodes, the graph and memory will be synchronized to avoid this issue.

Added features:

  • Restore Working Memory state (minus reduced and/or removed orphan nodes) after graph reduction
  • Added Memory::setDummyDictionnary() to avoid populating the dictionary with original descriptors, populate with empty descriptors instead to save RAM and initialization time.
    • Note that there is still a significant overhead in RAM even if the descriptors are empty (for 5M words with empty descriptors, that is about 1.7 GB of memory). Didn't find a way yet to avoid recreating all VisualWord objects while not breaking other stuff. EDIT: recheck again if we could pass a nullptr instead of empty VisualWord. An empty VisualWord still include all the overhead of a cv::Mat's header. Doublecheck that the signature->word references are still correctly updated. EDIT 2: We cannot use nullptr because the words need to keep track of the signatures they reference. I think the cleanest way would be to create a DummyDictionary class inheriting from VWDictionary and override functions to not use VisualWord objects, but keep track of words references in a simple map. Keeping this for a future PR though, lets merge this one.
  • Using dummy dictionary for rtabmap-addMoreLoopClosures tool too.

@matlabbe
matlabbe marked this pull request as ready for review July 10, 2026 23:57
@matlabbe
matlabbe merged commit 8999828 into master Jul 29, 2026
27 checks passed
@matlabbe
matlabbe deleted the reduce_graph_orphan_nodes branch July 29, 2026 15:19
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.

1 participant