You can set parameter "Odom/ResetCountdown" to 1 (default 0) for the visual odometry node:
<param name="Odom/ResetCountdown" type="string" value="1"/>
This will make the odometry automatically resets on the last known position when it is lost. That means that it will introduce inconsistencies in the map created. For example, the robot moved in a featureless environment for about 3 meters, and when features can be tracked again, the odometry is reset 3 meters back.
Other solutions:
- use the wheel odometry instead of the visual odometry
- call service "/rtabmap/reset_odom" when odometry is lost (either detect null odometry coming from odometry node or use "lost" field of
rtabmap/OdomInfo message), this will make odometry to reset on Identity transform, which when detected by rtabmap, create a new map. You will loose the previous map until a loop closure is found back between the new and previous maps, but you will have a consistent global map.