introlab / rtabmap

RTAB-Map library and standalone application
https://introlab.github.io/rtabmap
Other
2.83k stars 787 forks source link

With MM enabled, WM is not decreasing when Mem/ReduceGraph=true and following specific conditions #1337

Open matlabbe opened 2 months ago

matlabbe commented 2 months ago

MM -> Memory Management

Conditions:

Following these conditions, all nodes in the map get immunized following this code because they could all fall under Bayes/PredictionLC size: https://github.com/introlab/rtabmap/blob/11a8057246f1bd52db5488e7725505c01ebfa477/corelib/src/Rtabmap.cpp#L2261-L2265

Without Mem/ReduceGraph, the maximum nodes immunized at this step would be Bayes/PredictionLC size x 2 (or 34 nodes with default value), then maximum immunized nodes would be 34 or RGBD/LocalImmunizationRatio (of whatever WM size is). However, when there are Link::kNeighborMerged links, that number can be higher because of this condition where indirectly loop closures are not ignored: https://github.com/introlab/rtabmap/blob/11a8057246f1bd52db5488e7725505c01ebfa477/corelib/src/Memory.cpp#L1544-L1573

Removing iter->second.type() == Link::kNeighborMerged there could be a solution though I am currently not entirely sure if it would work as expected in all cases. For example, assuming we have the graph state as below and we want to retrieve around Node 42 (blue links are Link::kNeighbor type and orange links are Link::kNeighborMerged type). If we remove that condition, it means we won't be able to immunize all red nodes (that are all actual neighbors of 42) because they are indirectly linked by a Link::kNeighborMerged link, but we want them immunized so that Bayes filter continues to retrieve appropriate nodes from LTM (and to correctly estimate loop closure hypotheses). image

With that figure, we can also see the current issue where neighbors of node 18 (including 3 and its neighbors) would be also immunized following the current condition. The question is how do we immunize red nodes without immunizing neighbors of 18 and below?