Skip to content

A ROS2 Jazzy package natively implementing ORB-SLAM3 VSLAM framework

License

Notifications You must be signed in to change notification settings

RikisuT/ros2_orb_slam3

 
 

Repository files navigation

ROS 2 ORB-SLAM3 Package

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.


Citation

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}
}

Key Features

  • 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.

1. Prerequisites

Before installing the package, please ensure you have the following dependencies.

Eigen3

sudo apt install libeigen3-dev

Pangolin

We 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 build

2. 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_PATH

If 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 ldconfig

OpenCV

Ubuntu 22.04 typically includes a compatible version of OpenCV. Verify you have at least version 4.2:

python3 -c "import cv2; print(cv2.__version__)"

2. Installation

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-install

3. Usage Examples

The 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.bash

Monocular Example

Terminal 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:=false

Terminal 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:=EuRoC

To enable IMU fusion, set use_imu:=true in the C++ node and provide an IMU topic in the Python node.

Stereo Example

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:=true

Terminal 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:=EuRoC

To run in stereo-only mode, set use_imu:=false in the C++ node.

Configuration Notes

  • The settings_name parameter corresponds to a camera calibration .yaml file located in the config/ 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).

About

A ROS2 Jazzy package natively implementing ORB-SLAM3 VSLAM framework

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C++ 98.2%
  • Python 1.3%
  • CMake 0.5%