RTAB-Map Mapping1. Contents1.1 Introduction to RTAB-Map1.2. RTAB-Map Working Principle2. Preparation3. Program Startup4. Instruction analysis
This section explains how to combine a vehicle chassis, LiDAR, and a depth camera to implement RTAB-Map mapping.
RTAB-MAP (Real-Time Appearance-Based Mapping) is a vision-based real-time simultaneous localization and mapping (SLAM) algorithm primarily used for mapping and navigation tasks in fields such as robotics and augmented reality. RTAB-Map has the following features.
This section requires entering commands in the terminal. The terminal you open depends on your motherboard type. This lesson uses the Raspberry Pi 5 as an example. For Raspberry Pi and Jetson-Nano boards, you need to open a terminal on the host computer and enter the command to enter the Docker container. Once inside the Docker container, enter the commands mentioned in this section in the terminal. For instructions on entering the Docker container from the host computer, refer to this product tutorial [Configuration and Operation Guide]--[Enter the Docker (Jetson Nano and Raspberry Pi 5 users, see here)].
For Orin boards, simply open a terminal and enter the commands mentioned in this lesson.
Due to performance limitations, the Raspberry Pi 5 and Jetson Nano cannot smoothly run the RTAB-Map algorithm in Docker on the motherboard. Therefore, a virtual machine is required to facilitate this. To enable distributed communication between the vehicle and the virtual machine, two steps are required:
The Orin motherboard can be run directly on the motherboard.
First, enter the following command in the robot terminal to start the chassis, radar, and camera.
xxxxxxxxxxros2 launch M3Pro_navigation rtab_bringup.launch.pyThen, open a terminal in the virtual machine and enter the following command to control the robotic arm to move to the mapping pose.
xxxxxxxxxxros2 topic pub /arm6_joints arm_msgs/msg/ArmJoints {"joint1: 90,joint2: 180,joint3: 5,joint4: 0,joint5: 90,joint6: 0,time: 1500"} --onceOpen a terminal in the virtual machine and enter the following command to start RTAB-Map mapping.
xxxxxxxxxxros2 launch rtabmap_launch rtabmap.launch.py rgb_topic:=/camera/color/image_raw depth_topic:=/camera/depth/image_raw camera_info_topic:=/camera/color/camera_info odom_topic:=/odom frame_id:=base_link use_sim_time:=false rviz:=true rtabmap_viz:=false approx_sync:=true approx_sync_max_interval:=0.01 qos:=2 visual_odometry:=false icp_odometry:=false subscribe_scan:=true sync_queue_size:=50 topic_queue_size:=50 rtabmap_args:="--delete_db_on_start"After successful startup, the image below appears.

Modify the settings in rviz to change the point cloud display to RGB, as shown below.

Finally, open a terminal in the virtual machine and enter the following command to enable keyboard control of the car's movement and mapping.
xxxxxxxxxxros2 run yahboomcar_ctrl yahboom_keyboard
Here, control the car's movement as slowly as possible. Press the [z] key to reduce the linear velocity and deceleration. Then, press the [i] key to move the car forward, the [,] key to move it backward, the [j] key to rotate the car left, and the [l] key to rotate the car right.
As shown below, the map is complete.

After the map is created, press Ctrl+C in the terminal where you launched rtabmap.launch.py to close the program. The map will be saved in /home/yahboom/.ros/rtabmap.db.
RTAB-Map mapping instructions are as follows:
xxxxxxxxxxros2 launch rtabmap_launch rtabmap.launch.py rgb_topic:=/camera/color/image_raw depth_topic:=/camera/depth/image_raw camera_info_topic:=/camera/color/camera_info odom_topic:=/odom frame_id:=base_link use_sim_time:=false rviz:=true rtabmap_viz:=false approx_sync:=true approx_sync_max_interval:=0.01 qos:=2 visual_odometry:=false icp_odometry:=false subscribe_scan:=true sync_queue_size:=50 topic_queue_size:=50 rtabmap_args:="--delete_db_on_start"rgb_topic: Color image topic
depth_topic: Depth image topic
camera_info_topic: Color camera internal reference topic
odom_topic: Odometry topic
frame_id: Robot base coordinate system name
use_sim_time: Whether to use simulation time
rviz: Whether to enable rviz display
rtabmap_viz: Whether to enable rtabmap plugin display
approx_sync: Whether to enable approximate time synchronization
approx_sync_max_interval: Maximum allowed synchronization time difference
visual_odometry: Whether to enable visual odometry
icp_odometry: Whether to enable ICP point cloud matching odometry
subscribe_scan: Whether to subscribe to lidar data
sync_queue_size: Time synchronization queue size
topic_queue_size: Single topic subscription queue size
rtabmap_args: Parameters passed directly to the RTAB-MAP core. Optional parameters include the following:
--delete_db_on_start:Clears the previous map database at startup.--Mem/IncrementalMemory false:Disables incremental memory mode (for pure positioning).--Rtabmap/DetectionRate 2:Sets the closed-loop detection rate (Hz).qos:Quality of Service (QoS policy). Optional parameters include: