Fixed some issues related to intermediate nodes and retrieval/immunization (#1733)

* Allow ignoring intermediate nodes when calculating WM size

* Fix the retrieval logic to avoid unnecessary code execution

* Making getWorkingMemSize(true) complexity O(1)

* Updated statistics to show STM size, WM size, immunized nodes without intermediate nodes count. Added two new statistics to track number of intermediate nodes in STM and WM.

* Correct the condition for counting intermediate nodes

* Restore the logic of retrieval 2/3 to avoid affecting updateAge

---------

Co-authored-by: matlabbe <[email protected]>
This commit is contained in:
Borong Yuan
2026-07-14 10:14:11 -07:00
committed by GitHub
co-authored by matlabbe
parent d96c30710e
commit 0f56dd4b43
5 changed files with 161 additions and 62 deletions
+5
View File
@@ -149,6 +149,9 @@ public:
//getters
const std::map<int, double> & getWorkingMem() const {return _workingMem;}
size_t getWorkingMemSize(bool ignoreIntermediateNodes = false) const;
int getWorkingMemIntermediateNodesCount() const {return _workingMemIntermediateNodesCount;}
int getStMemIntermediateNodesCount() const {return _stMemIntermediateNodesCount;}
const std::set<int> & getStMem() const {return _stMem;}
int getMaxStMemSize() const {return _maxStMemSize;}
std::multimap<int, Link> getNeighborLinks(int signatureId,
@@ -360,6 +363,8 @@ private:
bool _memoryChanged; // False by default, become true only when Memory::update() is called.
bool _linksChanged; // False by default, become true when links are modified.
int _signaturesAdded;
int _workingMemIntermediateNodesCount; // number of nodes with weight==-1 currently in _workingMem
int _stMemIntermediateNodesCount; // number of nodes with weight==-1 currently in _stMem
bool _allNodesInWM;
bool _receivingOdometryFeatures;
GPS _gpsOrigin;
@@ -137,7 +137,9 @@ class RTABMAP_CORE_EXPORT Statistics
RTABMAP_STATS(NeighborLinkRefining, Pts,);
RTABMAP_STATS(Memory, Working_memory_size,);
RTABMAP_STATS(Memory, Working_memory_inter_size,);
RTABMAP_STATS(Memory, Short_time_memory_size,);
RTABMAP_STATS(Memory, Short_time_memory_inter_size,);
RTABMAP_STATS(Memory, Database_memory_used, MB);
RTABMAP_STATS(Memory, Signatures_removed,);
RTABMAP_STATS(Memory, Immunized_globally,);