| Component | Details |
|---|---|
| Camera | Intel RealSense D435i (USB 3) |
| ROS 2 | Jazzy/Humble |
| SLAM | RTAB-Map 4.56 |
| Packages | realsense2_camera, rtabmap_ros, imu_filter_madgwick |
flowchart LR
subgraph cam["RealSense D435i"]
rgb["RGB stream 640×360 @ 30 Hz"]
depth["Depth stream aligned to RGB"]
imu["IMU accel + gyro"]
end
rgb --> odom["rgbd_odometry"]
depth --> odom
imu --> madgwick["imu_filter_madgwick"]
madgwick --> imu_data["/imu/data"]
odom --> rtabmap["rtabmap"]
imu_data --> rtabmap
rtabmap --> db["~/.ros/rtabmap.db"]
rtabmap --> rviz["RViz2"]
sudo apt install ros-jazzy-realsense2-camera \
ros-jazzy-rtabmap-ros \
ros-jazzy-imu-filter-madgwick \
cloudcomparers-enumerate-devices
# Must show: Intel RealSense Depth Camera 435iIf not detected: unplug and replug the USB 3 cable (blue port), then retry.
cd ~/path/to/Visual-Slam/ros2_ws
colcon build --packages-select point_cloud anubi_slam
source install/setup.bashsource ~/path/to/Visual-Slam/ros2_ws/install/setup.bash
ros2 launch anubi_slam slam.launch.pyros2 launch anubi_slam slam.launch.py delete_db:=false| Node | Role |
|---|---|
realsense2_camera_node |
Streams RGB, aligned depth, IMU |
imu_filter_madgwick_node |
Fuses accel + gyro → quaternion |
rgbd_odometry |
Estimates camera motion frame-by-frame |
rtabmap |
Builds map, detects loop closures, saves to DB |
rviz2 |
Live visualization |
Watch the terminal for:
Odom: quality=87 ... ← good, start moving
Odom: quality=0 ... ← tracking lost, stop and recover
Wait for quality > 20 before moving.
| Do | Don't |
|---|---|
| Point at textured surfaces (books, objects, walls with posters) | Point at blank walls or ceilings |
| Move slowly (~0.3 m/s) | Make fast rotations |
| Keep 70%+ overlap between consecutive views | Jump or shake the camera |
| Return to start position to trigger loop closure | Cover the lens |
When you return to a previously seen area, a red edge appears in the RViz MapGraph panel. This corrects accumulated drift and is essential for an accurate map.
The map is saved automatically to ~/.ros/rtabmap.db when you press Ctrl+C.
To also export as a point cloud file:
# Export .ply (default output: ~/.ros/rtabmap_cloud.ply)
rtabmap-export --cloud ~/.ros/rtabmap.db
# Export with colour
rtabmap-export --cloud --texture ~/.ros/rtabmap.db
# Save to a custom path
rtabmap-export --cloud --output /path/to/my_map.ply ~/.ros/rtabmap.dbTo save the map to a specific database path:
# Set custom DB path in launch
ros2 launch anubi_slam slam.launch.py
# Then edit slam.launch.py and add to rtabmap parameters:
# 'database_path': '/path/to/my_map.db'rtabmap-databaseViewer ~/.ros/rtabmap.dbInside the viewer:
- Edit → View 3D Map — full coloured point cloud
- View → Graph — pose graph with loop closure edges
- Edit → Export Clouds — export to .ply/.pcd
CloudCompare ~/.ros/rtabmap_cloud.ply
# or the lightweight viewer:
ccViewer ~/.ros/rtabmap_cloud.plyUseful CloudCompare tools:
- Edit → Colors → Height Ramp — colour by height
- Tools → Statistics — point density, noise analysis
- Edit → Subsample — reduce point count for performance
RViz2 opens automatically with the launch file. Key displays:
| Panel | Shows |
|---|---|
| MapCloud | Growing 3D coloured map |
| MapGraph | Pose graph — blue=sequential, red=loop closure |
| LocalCloud | What the camera sees right now |
| Trajectory | Camera path (green line) |
| OccupancyMap | 2D top-down floorplan |
| TF | Coordinate frames — smooth motion = good tracking |
| RGBImage | Live colour feed |
ros2 run rqt_tf_tree rqt_tf_treeExpected structure:
map
└── odom
└── camera_link
├── camera_color_optical_frame
├── camera_depth_optical_frame
└── camera_imu_optical_frame
If map → odom is missing, RTAB-Map has not initialised yet (wait for quality > 0).
- Point camera at a textured scene (not a blank wall)
- Move more slowly
- Lower
Vis/MinInliersinslam.launch.py(currently set to 10)
# Reload udev rules
sudo udevadm control --reload-rules && sudo udevadm trigger
# Unplug and replug the camera, then retry
rs-enumerate-devicestouch ~/path/to/Visual-Slam/ros2_ws/src/realsense-ros/COLCON_IGNORE
rm -rf ~/path/to/Visual-Slam/ros2_ws/install/realsense2_camera
colcon build --packages-select anubi_slam~/path/to/Visual-Slam/ros2_ws/src/myenv/bin/pip install catkin_pkg lark empy
rm -rf ~/path/to/Visual-Slam/ros2_ws/build/point_cloud
colcon build --packages-select point_cloud anubi_slam