introlab / rtabmap_ros

RTAB-Map's ROS package.
http://wiki.ros.org/rtabmap_ros
BSD 3-Clause "New" or "Revised" License
916 stars 549 forks source link

Loop Closure Notification In Map Data Callback #1135

Closed alec-luterman closed 3 months ago

alec-luterman commented 3 months ago

Hello, I am trying to update the position of RViz markers that were placed on top of the map for detected objects when there is a loop closure, and I was wondering if there was a way to know if there was a loop closure from the map data callback instead of just recalculating the position of the markers during each callback in order to not perform unnecessary transforms. When I was trying to see potential ways to do this, it appears that checking if msg->graph.links.size() does not equal to +1 from the previous callback works visually and seems to correspond with loop closure based on the messages printed out in the terminal, but I am not sure if this is accurate. What is the best way to check for loop closure from the mapdata message? Thank you

matlabbe commented 3 months ago

You could make an exact synchronizer to subscribe to both /rtabmap/info and rtabmap/mapData topics and access them in same callback. In MapInfo, you can know there was a loop closure if any of these fields is not 0:

int32 loopClosureId
int32 proximityDetectionId
int32 landmarkId
alec-luterman commented 3 months ago

Thank you