Skip to main content
ORB-SLAM3 provides ROS integration for processing live camera and IMU data. This guide covers building ROS nodes, configuration, and running with ROS bags or live sensors.

Overview

ORB-SLAM3 ROS nodes support all sensor configurations:
  • Mono: Monocular camera
  • Mono_Inertial: Monocular camera with IMU
  • Stereo: Stereo camera pair
  • Stereo_Inertial: Stereo cameras with IMU
  • RGBD: RGB-D depth camera
  • MonoAR: Monocular with augmented reality demo
ROS integration has been tested with ROS Melodic on Ubuntu 18.04. It should work with other ROS distributions with minimal modifications.

Building ROS Nodes

Prerequisites

Before building ROS nodes:
  1. Install ROS: Follow instructions at ros.org
  2. Build ORB-SLAM3: Complete the main build process first
  3. Source ROS: source /opt/ros/melodic/setup.bash

Setup ROS Package Path

1

Add ORB-SLAM3 to ROS package path

Edit your ~/.bashrc file:
gedit ~/.bashrc
2

Append the path

Add this line at the end (replace PATH with your ORB-SLAM3 directory):
export ROS_PACKAGE_PATH=${ROS_PACKAGE_PATH}:PATH/ORB_SLAM3/Examples_old/ROS
3

Source the updated bashrc

source ~/.bashrc

Build the ROS Nodes

Use the provided build script:
cd ORB_SLAM3
chmod +x build_ros.sh
./build_ros.sh
This script:
  • Navigates to Examples_old/ROS/ORB_SLAM3
  • Creates a build directory
  • Runs CMake with ROS_BUILD_TYPE=Release
  • Compiles all ROS nodes

Build Output

After successful compilation, executables are created:
Examples_old/ROS/ORB_SLAM3/build/
├── Mono                # Monocular node
├── MonoAR              # Monocular AR demo
├── Stereo              # Stereo node
├── RGBD                # RGB-D node
├── Mono_Inertial       # Monocular-Inertial node
└── Stereo_Inertial     # Stereo-Inertial node

ROS Node Types

Monocular Node

Processes monocular camera images from /camera/image_raw:
rosrun ORB_SLAM3 Mono \
  PATH_TO_VOCABULARY \
  PATH_TO_SETTINGS_FILE
Example:
rosrun ORB_SLAM3 Mono \
  Vocabulary/ORBvoc.txt \
  Examples/Monocular/EuRoC.yaml
Topics subscribed:
  • /camera/image_raw (sensor_msgs/Image)

Monocular-Inertial Node

Processes monocular images with IMU data:
rosrun ORB_SLAM3 Mono_Inertial \
  PATH_TO_VOCABULARY \
  PATH_TO_SETTINGS_FILE \
  [EQUALIZATION]
Example:
rosrun ORB_SLAM3 Mono_Inertial \
  Vocabulary/ORBvoc.txt \
  Examples/Monocular-Inertial/EuRoC.yaml
Topics subscribed:
  • /camera/image_raw (sensor_msgs/Image)
  • /imu (sensor_msgs/Imu)
Optional argument:
  • EQUALIZATION: Set to true to apply CLAHE histogram equalization (useful for TUM-VI dataset)
For challenging lighting conditions or low-contrast scenes, enable equalization:
rosrun ORB_SLAM3 Mono_Inertial Vocabulary/ORBvoc.txt config.yaml true

Stereo Node

Processes stereo camera pair:
rosrun ORB_SLAM3 Stereo \
  PATH_TO_VOCABULARY \
  PATH_TO_SETTINGS_FILE \
  ONLINE_RECTIFICATION
Example:
rosrun ORB_SLAM3 Stereo \
  Vocabulary/ORBvoc.txt \
  Examples/Stereo/EuRoC.yaml \
  true
Topics subscribed:
  • /camera/left/image_raw (sensor_msgs/Image)
  • /camera/right/image_raw (sensor_msgs/Image)
Online rectification:
  • true: Node rectifies images (provide rectification matrices in YAML)
  • false: Images must be pre-rectified
  • Not needed for fisheye cameras (works with original images)

Stereo-Inertial Node

Processes stereo cameras with IMU:
rosrun ORB_SLAM3 Stereo_Inertial \
  PATH_TO_VOCABULARY \
  PATH_TO_SETTINGS_FILE \
  ONLINE_RECTIFICATION \
  [EQUALIZATION]
Example:
rosrun ORB_SLAM3 Stereo_Inertial \
  Vocabulary/ORBvoc.txt \
  Examples/Stereo-Inertial/EuRoC.yaml \
  true
Topics subscribed:
  • /camera/left/image_raw (sensor_msgs/Image)
  • /camera/right/image_raw (sensor_msgs/Image)
  • /imu (sensor_msgs/Imu)

RGB-D Node

Processes RGB-D depth camera:
rosrun ORB_SLAM3 RGBD \
  PATH_TO_VOCABULARY \
  PATH_TO_SETTINGS_FILE
Example:
rosrun ORB_SLAM3 RGBD \
  Vocabulary/ORBvoc.txt \
  Examples/RGB-D/TUM1.yaml
Topics subscribed:
  • /camera/rgb/image_raw (sensor_msgs/Image)
  • /camera/depth_registered/image_raw (sensor_msgs/Image)
Depth images must be registered (aligned) to the RGB frame. Configure RGBD.DepthMapFactor correctly in your YAML file.

Topic Configuration

By default, ROS nodes subscribe to standard topics. Remap topics when running with different camera drivers:

Topic Remapping

# Remap monocular topic
rosrun ORB_SLAM3 Mono Vocabulary/ORBvoc.txt config.yaml \
  /camera/image_raw:=/usb_cam/image_raw

# Remap stereo topics
rosrun ORB_SLAM3 Stereo Vocabulary/ORBvoc.txt config.yaml true \
  /camera/left/image_raw:=/stereo/left/image_rect \
  /camera/right/image_raw:=/stereo/right/image_rect

# Remap IMU topic
rosrun ORB_SLAM3 Mono_Inertial Vocabulary/ORBvoc.txt config.yaml \
  /imu:=/mavros/imu/data

Default Topic Names

Monocular

  • /camera/image_raw

Stereo

  • /camera/left/image_raw
  • /camera/right/image_raw

RGB-D

  • /camera/rgb/image_raw
  • /camera/depth_registered/image_raw

IMU

  • /imu

Running with ROS Bags

Test ORB-SLAM3 with recorded ROS bags:

Complete Example: EuRoC Stereo-Inertial

1

Download EuRoC dataset

wget http://robotics.ethz.ch/~asl-datasets/ijrr_euroc_mav_dataset/\
machine_hall/MH_01_easy/MH_01_easy.bag
2

Start roscore

In terminal 1:
roscore
3

Launch ORB-SLAM3 node

In terminal 2:
rosrun ORB_SLAM3 Stereo_Inertial \
  Vocabulary/ORBvoc.txt \
  Examples/Stereo-Inertial/EuRoC.yaml \
  true
4

Play the rosbag

In terminal 3, wait for ORB-SLAM3 to load vocabulary, then:
rosbag play --pause MH_01_easy.bag \
  /cam0/image_raw:=/camera/left/image_raw \
  /cam1/image_raw:=/camera/right/image_raw \
  /imu0:=/imu
Press space to start playback.

Playback Tips

# Play at normal speed
rosbag play dataset.bag

TUM-VI Dataset Rebag Issue

TUM-VI rosbags may have playback issues due to large chunk size:
# Rebag with default chunk size
rosrun rosbag fastrebag.py \
  dataset-room1_512_16.bag \
  dataset-room1_512_16_small_chunks.bag
Then play the rebbagged file normally.

Running with Live Cameras

Using RealSense Cameras

For Intel RealSense cameras, use the realsense-ros package:
# Install RealSense ROS wrapper
sudo apt-get install ros-melodic-realsense2-camera

# Launch RealSense node (D435i example)
roslaunch realsense2_camera rs_camera.launch \
  enable_gyro:=true \
  enable_accel:=true \
  unite_imu_method:=linear_interpolation

# In another terminal, run ORB-SLAM3
rosrun ORB_SLAM3 Stereo_Inertial \
  Vocabulary/ORBvoc.txt \
  Examples/Stereo-Inertial/RealSense_D435i.yaml \
  false \
  /camera/infra1/image_rect_raw:=/camera/left/image_raw \
  /camera/infra2/image_rect_raw:=/camera/right/image_raw \
  /camera/imu:=/imu

USB Webcam

For simple USB cameras:
# Install usb_cam package
sudo apt-get install ros-melodic-usb-cam

# Launch camera node
rosrun usb_cam usb_cam_node

# Run ORB-SLAM3 monocular
rosrun ORB_SLAM3 Mono \
  Vocabulary/ORBvoc.txt \
  my_webcam_config.yaml \
  /usb_cam/image_raw:=/camera/image_raw

Troubleshooting

Cause: ROS can’t find ORB-SLAM3 package.Solution:
# Check ROS_PACKAGE_PATH
echo $ROS_PACKAGE_PATH

# Should include: /path/to/ORB_SLAM3/Examples_old/ROS

# If not, add to ~/.bashrc
export ROS_PACKAGE_PATH=${ROS_PACKAGE_PATH}:/path/to/ORB_SLAM3/Examples_old/ROS
source ~/.bashrc
Cause: Text vocabulary file is slow to parse.Solution: Be patient (30-60 seconds). Consider converting to binary format for faster loading.
# Wait for this message before playing rosbag
# "ORB-SLAM3 System is ready."
Cause: Topic mismatch or message type incompatibility.Solution:
# List active topics
rostopic list

# Check message type
rostopic info /camera/image_raw

# Should be: sensor_msgs/Image

# Monitor topic
rostopic hz /camera/image_raw

# Use correct topic remapping
rosrun ORB_SLAM3 Mono vocab.txt config.yaml \
  /camera/image_raw:=/your/actual/topic
Cause: Insufficient IMU data, poor calibration, or timestamp issues.Solution:
  • Ensure IMU publishing at correct frequency (check config: IMU.Frequency)
  • Verify camera-IMU timestamps are synchronized
  • Check IMU calibration parameters in YAML
  • Provide sufficient motion during initialization (15-20 seconds)
# Check IMU topic
rostopic hz /imu

# Should match IMU.Frequency in config (e.g., 200 Hz)
Cause: Incorrect camera calibration or configuration.Solution:
  • Verify camera calibration parameters in YAML
  • Check image resolution matches config (Camera.width, Camera.height)
  • Ensure vocabulary file loaded correctly
  • Test with lower ORB threshold (ORBextractor.minThFAST: 5)
  • Verify sufficient visual texture in scene
Cause: Stereo synchronization or rectification issues.Solution:
  • Ensure stereo images are properly synchronized
  • Check Stereo.T_c1_c2 transformation is correct
  • Verify baseline (Stereo.ThDepth) is appropriate
  • For pinhole: Enable online rectification or pre-rectify images
# Check stereo synchronization
rosrun image_view stereo_view \
  stereo:=/camera image:=image_raw

Performance Optimization

Real-Time Performance Tips

1

Reduce ORB features

Lower ORBextractor.nFeatures to 800-1000 for faster processing:
ORBextractor.nFeatures: 800
2

Disable viewer

Run without visualization for maximum performance:
// Modify ROS node or build with viewer disabled
System SLAM(argv[1], argv[2], System::STEREO, false);
3

CPU governor

Set CPU to performance mode:
sudo cpufreq-set -g performance
4

Message throttling

Reduce camera framerate if needed:
rosrun topic_tools throttle messages /camera/image_raw 15.0

Saving Trajectory

After running ORB-SLAM3, save the estimated trajectory:
# In the ORB-SLAM3 terminal, after shutdown
# Trajectories are automatically saved to:
ls -l KeyFrameTrajectory.txt
ls -l CameraTrajectory.txt
Use these files for evaluation against ground truth.

Next Steps

Build docs developers (and LLMs) love