(!) Please ask about problems and questions regarding this tutorial on answers.ros.org. Don't forget to include in your question the link to this page, the versions of your OS & ROS, and also add appropriate tags.

RGB-D Handheld Mapping

Description: This tutorial shows how to use rtabmap_ros out-of-the-box with a Kinect-like sensor in mapping mode or localization mode.

Tutorial Level: BEGINNER

Next Tutorial: Stereo Handheld Mapping

RGB and depth sensors

The RGB-D sensors which are OpenNI and OpenNI2 compliant would work out-of-the-box using openni_launch, openni2_launch, freenect_launch, iai_kinect2 or Zed packages. Sensors tested:

  • Kinect for Xbox 360

    • $ roslaunch openni_launch openni.launch depth_registration:=true
    • $ roslaunch freenect_launch freenect.launch depth_registration:=true
  • XtionPRO Live

    • $ roslaunch openni2_launch openni2.launch depth_registration:=true
  • Kinect v2 (Xbox One)

    • Make sure it is calibrated: see kinect2_calibration.

    • $ roslaunch kinect2_bridge kinect2_bridge.launch publish_tf:=true
  • Stereolabs ZED (make sure you have this pull request to avoid synchronization issues) Updated April 29 2020

    • Choose between A or B:
    • // A) With rtabmap odometry:
      roslaunch zed_wrapper zed_no_tf.launch
      rosrun dynamic_reconfigure dynparam set zed_node depth_confidence 99
      rosrun dynamic_reconfigure dynparam set zed_node depth_texture_conf 90
      rosrun dynamic_reconfigure dynparam set zed_node depth_confidence 100
      // B) With zed odometry:
      roslaunch zed_wrapper zed2.launch
      rosrun dynamic_reconfigure dynparam set /zed2/zed_node depth_confidence 99
      rosrun dynamic_reconfigure dynparam set /zed2/zed_node depth_texture_conf 90
      rosrun dynamic_reconfigure dynparam set /zed2/zed_node depth_confidence 100
      // To avoid map -> odom TF published by zed, set tracking/publish_map_tf to false for zed_wrapper_node
      // Note: the repeating depth_confidence is not an error, it seems on the first call nothing happens, we need to redo second time with a different value.
  • RealSense R200 and ZR300

    • #R200
      $ roslaunch realsense_camera r200_nodelet_rgbd.launch
      $ roslaunch realsense_camera zr300_nodelet_rgdb.launch
      // To get registration without empty lines
      $ rosrun rtabmap_ros pointcloud_to_depthimage \
          cloud:=/camera/depth/points \
          camera_info:=/camera/rgb/camera_info \
          image_raw:=/camera/depth/points/image_raw \
          image:=/camera/depth/points/image \
          _approx:=false \
  • RealSense D415/D435

    • $ roslaunch realsense2_camera rs_camera.launch align_depth:=true
  • RealSense D435i

    • # ISSUE: Use unite_imu_method:="copy" if imu topics keep stopping
      $ roslaunch realsense2_camera rs_camera.launch align_depth:=true unite_imu_method:="linear_interpolation" enable_gyro:=true enable_accel:=true
      $ rosrun imu_filter_madgwick imu_filter_node \
          _use_mag:=false \
          _publish_tf:=false \
          _world_frame:="enu" \
          /imu/data_raw:=/camera/imu \
  • RealSense D400+T265

    • Based on your setup, make sure to edit the static transform between the cameras in that launch file.

    • $ roslaunch realsense2_camera rs_d400_and_t265.launch

    • $ roslaunch mynt_eye_ros_wrapper mynteye.launch
      $ rosrun tf static_transform_publisher 0 0 0 -1.5707963267948966 0 -1.5707963267948966  base_link mynteye_link 100

Mapping mode

There are two choices for online visualization: rtabmapviz or rviz. With the RVIZ plugin rtabmap/MapCloud, the clouds can be incrementally added to RVIZ. However using rtabmapviz, the interface should look like the tutorials of the standalone version. With the launch file rtabmap.launch below, set rviz:=true to open rviz and rtabmapviz:=true to open rtabmapviz (default true) for visualization.

  • For freenect, openni and openni2:

    •  $ roslaunch rtabmap_ros rtabmap.launch rtabmap_args:="--delete_db_on_start"
  • For kinect2_bridge:

    •  $ rosrun tf static_transform_publisher 0 0 0 -1.5707963267948966 0 -1.5707963267948966 camera_link kinect2_link 100
       $ roslaunch rtabmap_ros rtabmap.launch \
          rtabmap_args:="--delete_db_on_start" \
          rgb_topic:=/kinect2/qhd/image_color_rect \
          depth_topic:=/kinect2/qhd/image_depth_rect \
          camera_info_topic:=/kinect2/qhd/camera_info \

    or for convenience: rgbd_mapping_kinect2.launch

    •  $ roslaunch rtabmap_ros rgbd_mapping_kinect2.launch resolution:=qhd
  • For Stereolabs ZED and ZED Mini

    • Choose between A or B (depending of the one chosen above):
       // A) With rtabmap odometry
       $ roslaunch rtabmap_ros rtabmap.launch \
          rtabmap_args:="--delete_db_on_start" \
          rgb_topic:=/zed_node/rgb/image_rect_color \
          depth_topic:=/zed_node/depth/depth_registered \
          camera_info_topic:=/zed_node/rgb/camera_info \
          frame_id:=base_link \
       // B) With zed odometry
       $ roslaunch rtabmap_ros rtabmap.launch \
          rtabmap_args:="--delete_db_on_start" \
          rgb_topic:=/zed2/zed_node/rgb/image_rect_color \
          depth_topic:=/zed2/zed_node/depth/depth_registered \
          camera_info_topic:=/zed2/zed_node/depth/camera_info \
          odom_topic:=/zed2/zed_node/odom \
          visual_odometry:=false \
          frame_id:=base_link \
          approx_sync:=false \
          rgbd_sync:=true \
    • An example package is provided by Stereolabs to directly launch a 3D mapping process using RTAB-map from the zed-ros-wrapper:

    •  $ roslaunch zed_rtabmap_example zed_rtabmap.launch
  • For RealSense R200 and ZR300

    •  $ roslaunch rtabmap_ros rtabmap.launch \
          rtabmap_args:="--delete_db_on_start" \
       // Using depth registered from `rtabmap_ros/pointcloud_to_depthimage`
       $ roslaunch rtabmap_ros rtabmap.launch \
          rtabmap_args:="--delete_db_on_start" \
  • For RealSense D415/D435

    •  $ roslaunch rtabmap_ros rtabmap.launch \
          rtabmap_args:="--delete_db_on_start" \
          depth_topic:=/camera/aligned_depth_to_color/image_raw \
          rgb_topic:=/camera/color/image_raw \
          camera_info_topic:=/camera/color/camera_info \
  • For RealSense D435i

    •  $ roslaunch rtabmap_ros rtabmap.launch \
          rtabmap_args:="--delete_db_on_start --Optimizer/GravitySigma 0.3" \
          depth_topic:=/camera/aligned_depth_to_color/image_raw \
          rgb_topic:=/camera/color/image_raw \
          camera_info_topic:=/camera/color/camera_info \
          approx_sync:=false \
          wait_imu_to_init:=true \
  • For RealSense D400+T265

    •  $ roslaunch rtabmap_ros rtabmap.launch \
         args:="-d --Mem/UseOdomGravity true --Optimizer/GravitySigma 0.3" \
         odom_topic:=/t265/odom/sample \
         frame_id:=t265_link \
         rgbd_sync:=true \
         depth_topic:=/d400/aligned_depth_to_color/image_raw \
         rgb_topic:=/d400/color/image_raw \
         camera_info_topic:=/d400/color/camera_info \
         approx_rgbd_sync:=false \
  • For MYNT EYE S

    •  $ roslaunch rtabmap_ros rtabmap.launch \
         rgb_topic:=/mynteye/left_rect/image_rect \
         camera_info_topic:=/mynteye/left_rect/camera_info \
         depth_topic:=/mynteye/depth/image_raw \
         frame_id:=base_link \

The rtabmap argument "--delete_db_on_start" is used to start mapping from a clean database. You can also reset the memory from rtabmapviz using the action "Edit->Delete memory", or by using this service :

  •  $ rosservice call /rtabmap/reset

You should see something like this:

RGB-D Mapping

  • If the background of the map turns RED, it is because the odometry is lost. Visit this page under Lost Odometry (RED screens!) section to know why this happens! To track again the odometry, replace the camera to the last position before the RED appeared and it should be able to recompute the odometry. Another way is to reset the odometry using the menu option "Edit->Reset odometry" (note that a new map is created each time the odometry is reset). See Odometry Auto-Reset for another way to handle odometry lost (reset and continue the same map).

Use external odometry

If you want to use external odometry (e.g., you want to use odometry from your robot), you can set these arguments: "visual_odometry:=false odom_topic:=/my_odometry".

Where is the map saved?


RTAB-Map provides a tool to browse data in the database:

$ rtabmap-databaseViewer ~/.ros/rtabmap.db

Localization mode

In localization mode, a map large enough (>30 locations) must be already created (using rgbd_mapping.launch above).

In rtabmapviz (GUI), click on "Localization" in the "Detection" menu. By looking over locations in the map, RTAB-Map would localize itself in it by finding a loop closure. Once a loop closure is found, the odometry is corrected and the current cloud will be aligned to the map.

You can play with the relocation behaviour by resetting the odometry. You can use form the GUI the Detection->"Reset odometry" action or call the service on the terminal like:

  • $ rosservice call /rtabmap/reset_odom


You can also start the launch file above directly in Localization mode with a previously built database. Set the parameter "Mem/IncrementalMemory" to "false". Also, when starting the rtabmap node, the argument "--delete_db_on_start" must not be set!

  • <node name="rtabmap" pkg="rtabmap_ros" type="rtabmap" output="screen" args="">
       <param name="Mem/IncrementalMemory" type="string" value="false"/>

Since recent versions, rtabmap.launch has "localization" argument for convenience:

  • $ roslaunch rtabmap_ros rtabmap.launch localization:=true

In the GUI, do Edit->"Download map" to download the map from the rtabmap node. At the start, you should see that the current displayed cloud is not aligned to the map, it is normal because the odometry is reset on each start. By looking over locations in the map, RTAB-Map would localize itself in it by finding a loop closure. Once a loop closure is found, the odometry is corrected and the map will appear with the current cloud aligned to it.

Wiki: rtabmap_ros/Tutorials/HandHeldMapping (last edited 2020-07-30 20:07:07 by MathieuLabbe)