This repository provides a "bare-bones" ROS 2 package for the original ORB-SLAM3 V1.0, focusing on a native and straightforward integration into the ROS 2 ecosystem. It's designed as a clean starting point for developers to incorporate ORB-SLAM3 into their projects without advanced features like RViz, TF, or launch files included by default.
The project structure is heavily influenced by the excellent ROS 1 port from thien94.
If you use this package in your research, please consider citing the original ORB-SLAM3 paper and our paper, which uses this package to solve the short-term relocalization problem:
@INPROCEEDINGS{kamal2024solving,
author={Kamal, Azmyin Md. and Dadson, Nenyi Kweku Nkensen and Gegg, Donovan and Barbalata, Corina},
booktitle={2024 IEEE International Conference on Advanced Intelligent Mechatronics (AIM)},
title={Solving Short-Term Relocalization Problems In Monocular Keyframe Visual SLAM Using Spatial And Semantic Data},
year={2024},
pages={615-622},
doi={10.1109/AIM55361.2024.10637187}}@article{ORBSLAM3_TRO,
title={{ORB-SLAM3}: An Accurate Open-Source Library for Visual, Visual-Inertial
and Multi-Map {SLAM}},
author={Campos, Carlos AND Elvira, Richard AND G\´omez, Juan J. AND Montiel,
Jos\'e M. M. AND Tard\'os, Juan D.},
journal={IEEE Transactions on Robotics},
volume={37},
number={6},
pages={1874-1890},
year={2021}
}- Builds ORB-SLAM3 v1.0 as a shared internal library.
- Includes required third-party libraries: DBoW2, g2o, and Sophus.
- Modern codebase requiring C++17 and CMake >= 3.8.
- Assumes modern dependencies: Eigen 3.3.0, OpenCV >= 4.2, and a recent version of Pangolin.
- Demonstrates a clean separation between a C++ processing node and a Python driver node.
Before installing the package, please ensure you have the following dependencies.
sudo apt install libeigen3-devWe will install Pangolin system-wide and configure the dynamic library path.
1. Install Dependencies & Build Pangolin
# Navigate to a suitable directory
cd ~/Documents
# Clone the repository
git clone https://github.com/stevenlovegrove/Pangolin
# Enter the directory and install prerequisites
cd Pangolin
./scripts/install_prerequisites.sh recommended
# Build and install Pangolin
cmake -B build
cmake --build build -j4
sudo cmake --install build2. Configure Dynamic Library Path
The linker needs to find the compiled Pangolin libraries (.so files).
First, check if /usr/local/lib is already in your library path:
echo $LD_LIBRARY_PATHIf it's not present, add it permanently to your .bashrc file:
echo 'export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib' >> ~/.bashrc
source ~/.bashrc
sudo ldconfigUbuntu 22.04 typically includes a compatible version of OpenCV. Verify you have at least version 4.2:
python3 -c "import cv2; print(cv2.__version__)"Follow these steps to create a new workspace, clone, and build the package.
Critical Note on Workspace Name: The Python driver nodes contain a hardcoded path that assumes your workspace is named ros2_orb_slam3_ws. If you use a different name, you must update this path manually in ros2_orb_slam3/ros2_orb_slam3/mono_driver_node.py and ros2_orb_slam3/ros2_orb_slam3/stereo_driver_node.py.
# 1. Create and navigate to your ROS 2 workspace
mkdir -p ~/ros2_orb_slam3_ws/src
cd ~/ros2_orb_slam3_ws/src
# 2. Clone the repository
git clone https://github.com/RikisuT/ros2_orb_slam3.git
# 3. Navigate to the workspace root
cd ~/ros2_orb_slam3_ws
# 4. Install dependencies
rosdep install -r --from-paths src --ignore-src -y --rosdistro jazzy
# 5. Source ROS 2 and build the package
source /opt/ros/jazzy/setup.bash
colcon build --symlink-installThe package works with live camera topics or data from ROS 2 bags. Image sequence runners from the original ORB-SLAM3 have been removed.
For each example, you will need two terminals. Remember to source your workspace in each new terminal:
cd ~/ros2_orb_slam3_ws/
source ./install/setup.bashTerminal 1 (C++ SLAM Node):
# Set use_imu:=false for monocular-only SLAM
ros2 run ros2_orb_slam3 mono_node_cpp --ros-args -p use_imu:=falseTerminal 2 (Python Driver Node):
# Replace /camera/image_raw with your actual image topic
ros2 run ros2_orb_slam3 mono_driver_node.py --ros-args \
-p image_topic:=/camera/image_raw \
-p settings_name:=EuRoCTo enable IMU fusion, set use_imu:=true in the C++ node and provide an IMU topic in the Python node.
Terminal 1 (C++ SLAM Node):
# Set use_imu:=true for stereo-inertial SLAM
ros2 run ros2_orb_slam3 stereo_node_cpp --ros-args -p use_imu:=trueTerminal 2 (Python Driver Node):
# Replace topics with your actual left, right, and IMU topics
ros2 run ros2_orb_slam3 stereo_driver_node.py --ros-args \
-p left_image_topic:=/cam0/image_raw \
-p right_image_topic:=/cam1/image_raw \
-p imu_topic:=/imu \
-p settings_name:=EuRoCTo run in stereo-only mode, set use_imu:=false in the C++ node.
- The
settings_nameparameter corresponds to a camera calibration.yamlfile located in theconfig/directory of this package. - You must provide a configuration file that matches your camera setup (e.g.,
EuRoC.yaml,TUM.yaml, or your own custom file).