Skip to content

Latest commit

 

History

History
137 lines (99 loc) · 3.68 KB

File metadata and controls

137 lines (99 loc) · 3.68 KB

RTAB-Map with SuperPoint & SuperGlue (AI-SLAM) Installation Guide

This guide documents the process to build RTAB-Map with LibTorch (C++11 ABI) support and integrate it with ROS 2.

1. Workspace & File Structure

Ensure your workspace is structured as follows for the scripts and commands in this guide to work correctly.

/media/thippe/SDV/Ubuntu/rtab_ws/
├── build/                      # Build artifacts
├── install/                    # Install artifacts
├── libtorch_cxx11/             # Extracted LibTorch (CXX11 ABI)
│   └── libtorch/
├── src/                        # Source code
│   ├── rtabmap/                # Git clone of introlab/rtabmap
│   └── SuperGluePretrainedNetwork/ # Git clone for Python matching
├── env_setup.bash              # Environment helper script
├── superpoint_v1.pt            # AI Model Weights
├── rtabmap.db                  # Generated database (after running)
└── trajectory_results.txt      # Output poses (after running)

2. Prerequisites (LibTorch)

Download and extract LibTorch (CXX11 ABI version) to your workspace.

cd /media/thippe/SDV/Ubuntu/rtab_ws
# Example link (adjust version as needed, must be cxx11 ABI)
wget https://download.pytorch.org/libtorch/cu121/libtorch-cxx11-abi-shared-with-deps-2.1.0%2Bcu121.zip
unzip libtorch-cxx11-abi-shared-with-deps-2.1.0+cu121.zip
mv libtorch libtorch_cxx11

3. Build Standalone RTAB-Map (System Install)

We must build the core library manually to ensure it links against LibTorch correctly.

cd /media/thippe/SDV/Ubuntu/rtab_ws/src
git clone https://github.com/introlab/rtabmap.git
cd rtabmap/build

# Configure CMake with AI options
cmake .. \
    -DCMAKE_BUILD_TYPE=Release \
    -DWITH_TORCH=ON \
    -DWITH_PYTHON=ON \
    -DTorch_DIR=/media/thippe/SDV/Ubuntu/rtab_ws/libtorch_cxx11/libtorch/share/cmake/Torch \
    -DCMAKE_PREFIX_PATH="/media/thippe/SDV/Ubuntu/rtab_ws/libtorch_cxx11/libtorch"

# Compile and Install
make -j$(nproc)
sudo make install
sudo ldconfig

4. Prepare AI Models

SuperPoint

Generate or download superpoint_v1.pt.

# Assuming generated by trace.py or downloaded
cp superpoint_v1.pt /media/thippe/SDV/Ubuntu/rtab_ws/

SuperGlue (Setup Dependency)

Clone the weights and bridge script.

cd /media/thippe/SDV/Ubuntu/rtab_ws/src
git clone --depth 1 https://github.com/magicleap/SuperGluePretrainedNetwork.git

# IMPORTANT: Copy the bridge script from RTAB-Map to this folder
cp ../src/rtabmap/corelib/src/python/rtabmap_superglue.py SuperGluePretrainedNetwork/

5. Build ROS Wrapper

We link rtabmap_ros against the system installed library we just built.

cd /media/thippe/SDV/Ubuntu/rtab_ws

# Prevent colcon from rebuilding the library locally
touch src/rtabmap/COLCON_IGNORE

# Clean workspace (optional but recommended)
rm -rf build/ install/

# Export LibTorch path for the linker
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/media/thippe/SDV/Ubuntu/rtab_ws/libtorch_cxx11/libtorch/lib

# Build ROS packages
colcon build --cmake-args -DCMAKE_BUILD_TYPE=Release

6. Verification

After installation, verifying the setup is critical.

Step 1: Environment Source

Always source the environment helper first.

cd /media/thippe/SDV/Ubuntu/rtab_ws
source env_setup.bash

Step 2: Check RTAB-Map Features

Verify that RTAB-Map was built with Torch and Python support.

rtabmap --version
# Expected Output:
# With SuperPoint Torch:    true
# With Python3:             true

Step 3: Check ROS 2 Packages

Ensure the ROS wrapper is found.

ros2 pkg list | grep rtabmap
# Expected Output:
# rtabmap
# rtabmap_ros
# rtabmap_launch
# ...