introlab / rtabmap

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

Question: How does the odometry detect past locations without running RTabMap Thread? #434

Open srinath-iko opened 5 years ago

srinath-iko commented 5 years ago

Hey @matlabbe,

I was playing around with the RtabMap source code and I was able to get loop closure of the transforms without running the Rtabmap thread. When researching the code, I was unable to pinpoint the location where this is taking place?

Could you help me know where exactly does the loop closure of the camera's location take place, i.e where the past location of the camera is referenced in the OdometryF2M code?

matlabbe commented 5 years ago

Hi,

Loop closure detection is done in this function: https://github.com/introlab/rtabmap/blob/536f00147905f76f714d5157458c7f5a226b9eb0/corelib/src/Rtabmap.cpp#L956

If this function is not called and you see loop closures, there is something strange. Odometry should be continous and doesn't detect loop closures. If you are using original OdometryF2M, if the local feature map size is huge (OdomF2M/MaxSize), the camera may appear jumping back to a previous location when coming back to an area still in the local feature map, though the jumps won't be huge. The actual motion estimation from last frame to local feature map is done here: https://github.com/introlab/rtabmap/blob/536f00147905f76f714d5157458c7f5a226b9eb0/corelib/src/odometry/OdometryF2M.cpp#L315-L320

Without disabling any threads, an efficient way to disable loop closure detection is to disable feature extraction from rtabmap, by setting Kp/MaxFeatures to -1. Also set RGBD/ProximityBySpace to false to avoid loop closures based on proximity.

cheers, Mathieu