-
Notifications
You must be signed in to change notification settings - Fork 787
Multi Session Mapping with RTAB Map Tango
This tutorial shows how to merge multiple RTAB-Map databases taken with RTAB-Map Tango. The same approach would apply with databases taken with RTAB-Map Desktop and rtabmap_ros
. To see a multi-session example from data captured on a robot, see the original Multi-Session tutorial.
Sketchfab link: https://skfb.ly/6p7YJ
- Avoid scanning mirrors: try to scan the contour but not directly in it to avoid surfaces behind the mirror added to map (e.g., in the room behind the mirror). However, if you forget or it is hard to do because of the environment layout, it is still possible to manually remove them afterward (as shown in next steps).
-
Anchors: to be able to merge automatically maps, loop closures should be detected between them. For example, try to start the new scan with the same point of view in front of a location mapped in previous scan. Use a location that has a lot of discriminative visual features under 4 meters, which we will refer as an "anchor location". For example, paintings or billboards on the walls are good anchors. A least one anchor should be revisited in new sessions to be able to merge them with a previous one.
- A way to find good anchors after pausing a session is to activate
Localization Mode
, then try to localize on the map currently loaded. When loop closures are detected with a lot of inliers (>100), that location is a good anchor. You can then reset the map, uncheckLocalization Mode
and start a new map from this location. When starting the new map, wait 5 seconds looking the anchor location, so that you will be sure that when merging the databases in the next steps, a loop closure will be found (sometimes the detector needs a couple of consecutive images of the same location to increase the loop closure hypotheses).
- A way to find good anchors after pausing a session is to activate
In this example, we scanned four databases using the scanning tips above. They can be downloaded here: MultiSessionTango.zip
- Updated 2018/09/30: fixed odometry covariance for RTAB-Map>=0.16.3 (see this issue)
-
Updated 2018/10/30: updated odom angular variance to 0.000001 and
RGBD/OptimizeMaxError
to 3. -
chalet1.db
(314 MB) -
chalet2.db
(68 MB) -
chalet3.db
(84 MB) -
chalet4.db
(35 MB)
Open RTAB-Map Desktop (>= 0.16.3) and click on "File->Open database...". Answer "Yes" to use parameters from the database, click "Cancel" to not download map, then click "File->Close database" to close the database. Now we have RTAB-Map Desktop set with the same parameters used to map on Tango. If you played with Localization Mode to test anchors like in the scanning tips, make sure that SLAM mode is enabled under "Preferences -> RTAB-Map Settings". You can do "ctrl-s" to save the current parameters.
(Version >=0.12.4 required) At the beginning of the first scan (chalet1.db
), I forgot to avoid the mirror in the bathroom. Here is how we can manually remove it from the 3D map. Click on "Tools->Edit Database..." and select chalet1.db
, then Database Viewer should open. Open the 3D View panel (View->3D View) to help seeing the 3D points behind the mirror. Using the first slider, move to image with ID=10.
-
Right-click on the corresponding image, then select "Show depth". We can see that there are depth values on the mirror:
-
Click on "Edit->Edit depth image...", a dialog should open. We can left click and move the mouse to clear depth values on the mirror. To go faster and be more precise on the edges, right-click on some depth values in the mirror, then select "Remove Cluster". This will remove depth values linked to one clicked:
-
Remove the remaining pixels with left click, then click Save to apply. Do the same for all images between 5 and 15 (where the mirror is visible), then close Database Viewer.
Open Preferences dialog and go to Source panel. Select Database
for the "Source Type" and set input rate to 5 Hz. Go down under "Database" section to select the databases.
-
Click on the "..." button to open the file dialog, then select the four databases and click Open:
-
Click "Yes" to use odometry from database.
-
click "Yes" to process all frames.
-
Make sure that in the Database path line that they are in the correct order (latest RTAB-Map version >=0.12.4 should be ordered), if not just edit the line.
-
Uncheck "Use database stamps as input rate." so that we use our 5 Hz previously set (to process datasets faster than real-time), otherwise the input rate will be the same as the acquisition (e.g., 1 Hz).
-
In Preferences->3D rendering, make sure "Show 3D clouds" is selected under Map column, set decimation to 3 and set Noise filtering radius to
0.05 m
with2
minimum neighbors. The last parameter will filter spurious points in the generated clouds. -
Click "Ok" to close Preferences dialog, do "File->New Database..." and click Start. You should see something like in this video:
-
When mapping the four databases is finished, press stop and you should see the four maps merged together.
- For convenience, to merge databases using command line instructions, we can use
rtabmap-reprocess
console application like this (version >=0.18 required):$ rtabmap-reprocess "chalet1.db;chalet2.db;chalet3.db;chalet4.db" merged.db
- With gravity constraints (version >=0.19.5 required):
$ rtabmap-reprocess --Optimizer/Strategy 1 --Optimizer/GravitySigma 0.3 --Mem/UseOdomGravity true "chalet1.db;chalet2.db;chalet3.db;chalet4.db" merged.db
To optimize the map even more, click on Tools->Post-processing, check Detect more loop closures and/or SBA, then click "Ok". Wait until the process has finished.
Click "File->Export 3D clouds..." and setup the panel as the following screenshot (taken from version 0.12.4) and click "Save". If you prefer exporting the point cloud and create the mesh (and texturing) with another software, you can see the Export Rasters Layer to MeshLab tutorial. Wait a couple of minutes then you will be able to save the OBJ.
The following examples are single session mapping, but have very similar workflow than shown in this tutorial to re-process the database. In these cases, the databases have been re-processed with different parameters to get more loop closures than with the default parameters.