Skip to content

Visual SLAM with RTAB‐Map

Sergei Grichine edited this page Jul 19, 2026 · 6 revisions

This is how RTAB-Map works on Seggy and Dragger

RTAB-Map ROS is the ROS 2 integration of the RTAB-Map (Real-Time Appearance-Based Mapping) library. It provides real-time visual and RGB-D SLAM, localization, loop-closure detection, and 2D/3D map generation using cameras, depth sensors, LiDAR, IMUs, GPS, and external odometry.

RTAB-Map ROS integrates with the ROS navigation stack (Nav2) by publishing the map frame, occupancy grids, point clouds, and localization estimates while supporting both mapping and localization against previously built maps.

RTAB-Map builds a graph of camera keyframes connected by odometry and loop closures. The map, images, point clouds, and graph are stored in an SQLite database (.db). The database can later be reopened for continued mapping or for localization, where the robot estimates its pose by matching live sensor data against the previously built map.

Installation

Use the binaries, on robot's RPi and on Dev machine:

sudo apt install ros-$ROS_DISTRO-rtabmap-ros

Note, that rtabmap_rviz GUI is also installed (to be used on Dev machine).

On Seggy robot (dev branch)

There are three common launch files:

  • launch/oakd.launch.py
  • launch/rtabmap.launch.py
  • launch/rtabmap_viz.launch.py (use on Dev machine)

Seggy's launch files are modified to start:

  • OAK-D Lite: robots/seggy/launch/seggy.sensors.launch.py
  • RTAB-Map: robots/seggy/launch/seggy.localizers.launch.py

Note: RTAB-Map is disabled by default: 'rtabmap_enabled', default='false'

On Seggy you can either set 'rtabmap_enabled' to true, or run RTAB-Map from a separate terminal:

ros2 launch articubot_one rtabmap.launch.py delete_db_on_start:=true database_path:=$HOME/.ros/seggy_lab.db

Running GUI on the Dev machine:

ros2 launch articubot_one rtabmap_viz.launch.py

On Dragger robot - outdoors (dev branch)

TBD

RTAB-Map ROS2 and Nav2 Integration (AI generated notes)

RTAB-Map integrates very well with Nav2 and is one of the most commonly used SLAM systems for camera-based navigation in ROS 2.

Overall Architecture

           Camera(s)      IMU       Wheel Odometry
               │           │              │
               └───────────┴──────────────┘
                           │
                     RTAB-Map ROS
                 (SLAM / Localization)
                           │
        ┌──────────────────┼──────────────────┐
        │                  │                  │
      map->odom TF     Occupancy Grid     Point Clouds
                           │
                           ▼
                         Nav2
              (Planner, Controller, Recovery)
                           │
                           ▼
                     Robot Motion

During Mapping

RTAB-Map uses camera images together with odometry to:

  • Estimate robot motion
  • Detect loop closures
  • Optimize the pose graph
  • Publish the map → odom transform
  • Generate a 2D occupancy grid
  • Optionally generate 3D point clouds and OctoMaps

Nav2 consumes the occupancy grid exactly like one produced by SLAM Toolbox.

During Localization

After a map has been created:

  1. RTAB-Map loads the saved .db database.
  2. The robot drives using camera and odometry.
  3. RTAB-Map recognizes previously visited places.
  4. It continuously updates the map → odom transform.

Nav2 never needs to know whether RTAB-Map is mapping or localizing—it simply uses the updated transform.

Data Exchanged with Nav2

Topic / TF Used by Nav2
map -> odom TF ✅ Robot localization
/rtabmap/map (OccupancyGrid) ✅ Global costmap
/tf ✅ Transform tree
/odometry/local (external) Input to RTAB-Map
/rtabmap/mapPath Optional visualization
/rtabmap/cloud_map Optional visualization

Nav2 provides:

  • Global planner
  • Local planner/controller
  • Recovery behaviors
  • Behavior Trees
  • Waypoint following

RTAB-Map is responsible only for localization and mapping.

Typical Transform Tree

map
 │
 └──► odom
        │
        └──► base_link
                 │
                 ├──► camera_link
                 ├──► imu_link
                 └──► laser_link
  • RTAB-Map publishes map → odom
  • robot_localization or wheel odometry publishes odom → base_link
  • robot_state_publisher publishes the fixed transforms from base_link to the sensors

Mapping Workflow

Drive robot
      │
      ▼
RTAB-Map builds map
      │
      ▼
Save database (.db)
      │
      ▼
Done

Localization Workflow

Load database
      │
      ▼
RTAB-Map recognizes places
      │
      ▼
Updates map->odom
      │
      ▼
Nav2 navigates

Advantages over SLAM Toolbox

For robots equipped with cameras such as the OAK-D Lite, RTAB-Map offers several advantages:

  • Works with RGB, stereo, and RGB-D cameras
  • Produces both 2D occupancy maps and rich 3D maps from the same sensor data
  • Uses appearance-based loop closure, which is effective in visually distinctive environments
  • Stores complete mapping sessions—including images, point clouds, poses, and graph topology—in a reusable SQLite database
  • Can fuse additional sensors such as LiDAR, IMUs, GPS, and AprilTags for improved robustness

Recommended Architecture

Wheel Encoders
        │
IMU ───► robot_localization
        │
        ▼
 /odometry/local
        │
        ▼
     RTAB-Map
        │
   map -> odom
        │
        ▼
       Nav2
        │
        ▼
   Drive Controller

This architecture cleanly separates responsibilities:

  • robot_localization provides a smooth, locally accurate odometry estimate (odom → base_link).
  • RTAB-Map performs global visual SLAM, detects loop closures, and publishes the corrected map → odom transform.
  • Nav2 uses the resulting global pose for path planning, obstacle avoidance, and autonomous navigation.

This is a robust and widely adopted architecture for indoor mobile robots using visual SLAM.

Useful links:

Clone this wiki locally