introlab / rtabmap_ros

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

saving incremental db #1072

Closed 360wcui closed 7 months ago

360wcui commented 7 months ago

Would it be possible to save db incrementally, e.g., rtabmap0001.db, rtabmap0002.db, and so on every 10 seconds or so. I tried to move rtabmap.db in the middle of mapping to some where else, the new data does not generate a new rtabmap.db in ~/.ros. Any advice would be greatly appreciated.

matlabbe commented 7 months ago

Each database is self-contained, we could not split them like this. The workaround would be to call:

rosservice call /rtabmap/load_database "database_path: 'rtabmap0001.db', clear: true"
# wait some time
rosservice call /rtabmap/load_database "database_path: 'rtabmap0002.db', clear: true"
# wait some time
rosservice call /rtabmap/load_database "database_path: 'rtabmap0003.db', clear: true"
...

Note however this will create a new session each time in a new database, so loop closures on runtime with previous databases won't be detected. Ideally, the robot would not move when a new database is created, to improve loop closure detection when merging back the databases afterwards:

rtabmap-reprocess "rtabmap0001.db;rtabmap0002.db;rtabmap0003.db" output.db

One major flaw is that for continuous mapping, you will lose an odometry constraint between each databases that would be useful to better optimize the map, even if a loop closure is detected between end and begin of consecutive databases. Well, knowing that the robot is not moving, after merging the databases, you could add an artificial constraint of Identity transform with very low covariance between last node and first node of consecutive sessions (to join them perfectly).