rtabmap_ros

repository·ros2·Indexed Aug 1, 2026

https://github.com/introlab/rtabmap_ros

The ROS2 port of the RTAB-Map (Real-Time Appearance-Based Mapping) package. It provides tools for SLAM and mapping using various sensors, including RGB-D cameras and LiDAR. The package supports integration with SuperPoint and SuperGlue for loop closure detection and odometry, and includes demos for TurtleBot3, Nav2, and outdoor stereo VSLAM.

Tokens
5.7K
Snippets
16
Records
42
Agent score
81%

What's inside rtabmap_ros

  1. Understand the FusionCore and icp_odometry architecture

    ros2

    The system uses a feedback loop to improve odometry accuracy:

    1. FusionCore (UKF): Fuses wheel odometry (/odom) and IMU (/imu) to provide a stable odom frame and continuous state at 100 Hz. It publishes /fusion/odom and the odom → base_footprint TF.
    2. icp_odometry: Uses /scan and FusionCore's odom as an initial guess (guess_frame_id: odom) to provide scan-level pose corrections. It publishes to /rtabmap/icp_odometry but does not publish its own TF (publish_tf: false).
    3. Feedback Loop: The output of icp_odometry is fed back into FusionCore as encoder2, providing tighter velocity corrections.
    4. rtabmap SLAM: Consumes icp_odometry output to build a global map and perform loop closures, providing the map → odom TF.
  2. Install rtabmap_ros from source

    ros2

    To build from source, first ensure any existing rtabmap binaries are removed to avoid conflicts. Then, clone both the rtabmap repository and the rtabmap_ros repository (specifically the ros2 branch) into your workspace, install dependencies with rosdep, and build using colcon.

    sudo apt remove ros-$ROS_DISTRO-rtabmap*
    
    cd ~/ros2_ws
    git clone https://github.com/introlab/rtabmap.git src/rtabmap
    git clone --branch ros2 https://github.com/introlab/rtabmap_ros.git src/rtabmap_ros
    rosdep update && rosdep install --from-paths src --ignore-src -r -y
    export MAKEFLAGS="-j6" # Can be ignored if you have a lot of RAM (>16GB)
    colcon build --symlink-install --cmake-args -DCMAKE_BUILD_TYPE=Release
  3. Available Docker images for rtabmap_ros

    ros2

    Docker images are available on introlab3it/rtabmap_ros.

    Available tags:

    • humble, jazzy: These images use the same versions as the ROS binaries released on ROS.
    • humble-latest, jazzy-latest: These images are automatically built from the latest version of rtabmap and rtabmap_ros from source, including dependencies not available via ROS binaries.
  4. Run rtabmap_viz in a Docker container with GUI support

    ros2

    To run rtabmap_viz with GUI support using the nvidia-docker2 approach, you must first set up X11 authentication on your host.

    1. Setup X11 Authentication (Run once)

    Execute these commands on your host to create an Xauthority file for the container:

    XAUTH=/tmp/.docker.xauth
    touch $XAUTH
    xauth nlist $DISPLAY | sed -e 's/^..../ffff/' | xauth -f $XAUTH nmerge -

    2. Launch the container

    Run the following command to start rtabmap_viz. This requires the --runtime=nvidia flag and specific environment variables for NVIDIA hardware acceleration and X11 forwarding.

    # Setup X11 (Run once)
    XAUTH=/tmp/.docker.xauth
    touch $XAUTH
    xauth nlist $DISPLAY | sed -e 's/^..../ffff/' | xauth -f $XAUTH nmerge -
    
    # Launch rtabmap_viz
    docker run -it --rm \
      --privileged \
      -e DISPLAY=$DISPLAY \
      -e QT_X11_NO_MITSHM=1 \
      -e NVIDIA_VISIBLE_DEVICES=all \
      -e NVIDIA_DRIVER_CAPABILITIES=all \
      -e XAUTHORITY=$XAUTH \
      -e OMP_WAIT_POLICY=passive \
      --user $UID \
      -e ROS_HOME=/tmp/.ros \
      -v ~/.ros:/tmp/.ros \
      --runtime=nvidia \
      --network=host \
      --ipc=host \
      -v $XAUTH:$XAUTH \
      -v /tmp/.X11-unix:/tmp/.X11-unix \
      introlab3it/rtabmap_ros:humble-latest \
      /bin/bash -c "ros2 run rtabmap_viz rtabmap_viz --ros-args -r __ns:=/rtabmap"
  5. Optimize SuperPoint performance by reusing features

    ros2

    To avoid redundant feature extraction in rtabmap for features already extracted in rgbd_odometry, you must modify the realsense_d435i_infra.launch.py file with the following changes:

    1. Add the parameter subscribe_sensor_data:=true to both rtabmap and rtabmap_viz nodes.
    2. Remap sensor_data:=odom_sensor_data/raw.
  6. Build rtabmap_ros with multi-RGBD or user data support

    ros2

    If you require support for multiple RGB-D cameras (rgbd_cameras > 1) or subscribe_user_data, you must enable these features via CMake arguments during the colcon build process.

    colcon build --symlink-install --cmake-args -DRTABMAP_SYNC_MULTI_RGBD=ON -DRTABMAP_SYNC_USER_DATA=ON -DCMAKE_BUILD_TYPE=Release
  7. Configure ROS2 logging for RTAB-Map

    ros2

    To ensure RTAB-Map's logs are ordered correctly with RCLCPP logs, set the following environment variables in your .bashrc. You can also enable colorized output for better readability.

    export RCUTILS_LOGGING_USE_STDOUT=1
    export RCUTILS_LOGGING_BUFFERED_STREAM=1
    # Optional, but if you like colored logs:
    export RCUTILS_COLORIZED_OUTPUT=1
  8. Configure FusionCore + icp_odometry Demo modes

    ros2

    You can customize the behavior of the TurtleBot3 FusionCore demo using launch arguments:

    • Localization mode: Use this if you have a saved map from a previous mapping run. This requires localization:=true.
    • Gazebo World: Change the simulation environment using the world argument.
    # Localization mode (requires saved map from a previous mapping run)
    ros2 launch rtabmap_demos turtlebot3_sim_fusioncore_icp_demo.launch.py localization:=true
    
    # Different Gazebo world
    ros2 launch rtabmap_demos turtlebot3_sim_fusioncore_icp_demo.launch.py world:=house
  9. Find sensor and robot integration examples

    ros2

    RTAB-Map provides examples for various hardware and robot configurations:

    • Sensor Integration (Stereo, RGB-D, 3D LiDAR): See the rtabmap_examples/launch sub-folder in the repository.
    • Robot Integration (Turtlebot3, Turtlebot4, Nav2): See the rtabmap_demos sub-folder in the repository.
  10. Launch RTAB-Map in ROS 2 using rtabmap.launch.py

    ros2

    The rtabmap.launch.py script in the rtabmap_launch package is the ROS 2 equivalent of the ROS 1 rtabmap.launch. It accepts the same arguments for configuring sensor topics, frame IDs, and RTAB-Map internal parameters.

    When migrating from ROS 1, ensure that your sensor driver (e.g., zed_wrapper) is launched first with appropriate settings (like disabling its own TF publishing if RTAB-Map is managing it), then launch rtabmap.launch.py providing the necessary topic names and synchronization settings.

    ros2 launch rtabmap_launch rtabmap.launch.py \
        rtabmap_args:="--delete_db_on_start" \
        rgb_topic:=/zed/zed_node/rgb/image_rect_color \
        depth_topic:=/zed/zed_node/depth/depth_registered \
        camera_info_topic:=/zed/zed_node/rgb/camera_info \
        frame_id:=zed_camera_link \
        approx_sync:=false \
        wait_imu_to_init:=true \
        imu_topic:=/zed_node/imu/data \
        rviz:=true
  11. Run the FusionCore + icp_odometry TurtleBot3 Gazebo Demo

    ros2

    This demo demonstrates a feedback loop between FusionCore and rtabmap's icp_odometry. FusionCore provides a stable initial guess for ICP via the odom frame, and the ICP output is fed back into FusionCore as a second velocity source (encoder2) to tighten the state estimate.

    To run the simulation, ensure your TURTLEBOT3_MODEL is set to waffle.

    export TURTLEBOT3_MODEL=waffle
    ros2 launch rtabmap_demos turtlebot3_sim_fusioncore_icp_demo.launch.py