-
Notifications
You must be signed in to change notification settings - Fork 3
Visual SLAM with RTAB‐Map
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.
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.pylaunch/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 integrates very well with Nav2 and is one of the most commonly used SLAM systems for camera-based navigation in ROS 2.
Camera(s) IMU Wheel Odometry
│ │ │
└───────────┴──────────────┘
│
RTAB-Map ROS
(SLAM / Localization)
│
┌──────────────────┼──────────────────┐
│ │ │
map->odom TF Occupancy Grid Point Clouds
│
▼
Nav2
(Planner, Controller, Recovery)
│
▼
Robot Motion
RTAB-Map uses camera images together with odometry to:
- Estimate robot motion
- Detect loop closures
- Optimize the pose graph
- Publish the
map → odomtransform - Generate a 2D occupancy grid
- Optionally generate 3D point clouds and OctoMaps
Nav2 consumes the occupancy grid exactly like one produced by SLAM Toolbox.
After a map has been created:
- RTAB-Map loads the saved
.dbdatabase. - The robot drives using camera and odometry.
- RTAB-Map recognizes previously visited places.
- It continuously updates the
map → odomtransform.
Nav2 never needs to know whether RTAB-Map is mapping or localizing—it simply uses the updated transform.
| 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.
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_linkto the sensors
Drive robot
│
▼
RTAB-Map builds map
│
▼
Save database (.db)
│
▼
Done
Load database
│
▼
RTAB-Map recognizes places
│
▼
Updates map->odom
│
▼
Nav2 navigates
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
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 → odomtransform. - 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.
- https://introlab.github.io/rtabmap/
- https://github.com/introlab/rtabmap_ros
- https://github.com/introlab/rtabmap_ros/tree/ros2/rtabmap_examples/launch
- https://wiki.ros.org/rtabmap_ros (Tutorials)
- https://wiki.ros.org/rtabmap_ros/Tutorials/MappingAndNavigationOnTurtlebot
- https://wiki.ros.org/rtabmap_ros/Tutorials/SetupOnYourRobot
- Introduction
- Notes and Status
- Machine Setup
- My Robots
- Seggy (indoors)
- Dragger (outdoors, GPS)
- Turtle (Create 1)
- Plucky (retired)
- Make Your Own Robot
- Sensors
- Wheels and Actuators
- Lawnmowers (under PX4 Autopilot)
- AI and Docker
- Random Notes