A ROS 2 workspace for 3D SLAM using RTABMap with a 6-wheel differential drive robot equipped with Intel RealSense D455 camera.
This project implements RGB-D SLAM (Simultaneous Localization and Mapping) using RTABMap on a custom differential drive robot. The robot can build 3D maps of indoor environments and localize itself within those maps.
- Type: 6-wheel differential drive robot
- Camera: Intel RealSense D455 (RGBD)
- Sensors: Wheel odometry, depth camera
- ROS 2: Humble Hawksbill
- SLAM: RTABMap 0.22.1
- Simulation: Gazebo 11
- Visualization: RViz2, RTABMap Viz
# ROS 2 Humble
sudo apt install ros-humble-desktop
# RTABMap
sudo apt install ros-humble-rtabmap-ros
# Gazebo
sudo apt install gazebo libgazebo-dev
# TurtleBot3 Gazebo ( for worlds )
sudo apt install ros-humble-turtlebot3-gazebo
# Additional dependencies
sudo apt install ros-humble-robot-state-publisher
sudo apt install ros-humble-xacro- Clone the repository
git clone <repo-url>
cd ws_ddmobile- Build the workspace
colcon build --symlink-install- Source the workspace
source install/setup.bashLaunch SLAM mode to build a new map:
# Launch Gazebo, RTABMap SLAM, and RTABMap Viz
ros2 launch mobile_dd_robot rtabmap_slam_robust.launch.py# Launch RViz2 separately
cd ws_ddmobile
source install/setup.bash
rviz2 -d src/mobile_dd_robot/config/rtabmap.rvizLaunch localization mode to use a pre-built map:
# Launch Gazebo, RTABMap Localization, and RTABMap Viz
ros2 launch mobile_dd_robot rtabmap_localization.launch.py# Launch RViz2
cd ws_ddmobile
source install/setup.bash
rviz2 -d src/mobile_dd_robot/config/rtabmap.rvizUse keyboard teleop to drive the robot:
# Terminal 3: Keyboard control
ros2 run teleop_twist_keyboard teleop_twist_keyboardws_ddmobile/
├── src/
│ └── mobile_dd_robot/
│ ├── launch/
│ │ ├── rtabmap_slam_robust.launch.py # SLAM mode
│ │ └── rtabmap_localization.launch.py # Localization mode
│ ├── model/
│ │ ├── robot_with_camera.xacro # Robot URDF
│ │ ├── robot.gazebo # Gazebo plugins
│ │ └── camera.xacro # Camera model
│ ├── config/
│ │ └── rtabmap.rviz # RViz configuration
│ ├── CMakeLists.txt
│ └── package.xml
├── build/ (gitignored - build artifacts)
├── install/ (gitignored - install files)
├── log/ (gitignored - build logs)
└── README.md
The launch files include optimized RTABMap parameters for robust SLAM:
- Grid Resolution: 5cm cells for occupancy grid
- Feature Detection: GFTT (Good Features To Track) with 1200 features
- Loop Closure: Threshold 0.10 for moderate-aggressive detection
- Ground Filtering: Points below -10cm filtered out
- Optimization: 30 iterations with g2o optimizer
'Grid/CellSize': '0.05' # 5cm resolution
'Grid/MinGroundHeight': '-0.1' # Filter underground artifacts
'Grid/MaxGroundHeight': '0.05' # Ground detection
'Vis/MaxFeatures': '1200' # Visual features
'Rtabmap/LoopThr': '0.10' # Loop closure threshold
'Optimizer/Iterations': '30' # Graph optimization
'RGBD/OptimizeMaxError': '3.0' # Max optimization error# Check if RTABMap is installed
ros2 pkg list | grep rtabmap- Launch SLAM mode
- Drive robot for 2-3 minutes
- Check map is being built in RTABMap Viz
- Verify occupancy grid in RViz2
- Look for loop closures in console
cd ws_ddmobile
colcon build --symlink-install# Rebuild single package
colcon build --symlink-install --packages-select mobile_dd_robot
# Source and test
source install/setup.bash
ros2 launch mobile_dd_robot rtabmap_slam_robust.launch.py- Modify launch files in
src/mobile_dd_robot/launch/ - Update robot model in
src/mobile_dd_robot/model/ - Rebuild:
colcon build --symlink-install - Test in simulation
/odom- Wheel odometry/camera/d455/image_raw- RGB image/camera/d455/depth/image_raw- Depth image/camera/d455/camera_info- Camera calibration/camera/d455/points- Point cloud/map- Occupancy grid map/rtabmap/grid_prob_map- Probability map
/cmd_vel- Velocity commands for robot control