Welcome to ROSMASTER M1 repository
12.RTAB-Map navigation
RTAB-Map Navigation
1. Content Description
This section explains how to implement RTAB-Map navigation by combining the robot chassis, LiDAR, depth camera, and Navigation2.
This section requires entering commands in the terminal. This lesson uses the Raspberry Pi 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 lesson in the terminal. For instructions on entering the Docker container from the host computer, refer to [01. Robot Configuration and Operation Guide] -- [4.Enter Docker (For JETSON Nano and RPi 5)].
For RDKX5 and Orin boards, simply open a terminal and enter the commands mentioned in this lesson.
2. Preparation
Due to performance limitations, the Raspberry Pi 5 and Jetson Nano cannot smoothly run the RTAB-Map algorithm in Docker on the board. Therefore, a virtual machine is required to facilitate this. To enable distributed communication between the car and the virtual machine, two steps are required:
- Both must be on the same local area network. This is most easily achieved by connecting to the same Wi-Fi network.
- Both devices must have the same ROS_DOMAIN_ID. The default ROS_DOMAIN_ID for the car is 30, and the default ROS_DOMAIN_ID for the virtual machine is also 30. If they are different, modify the virtual machine's ROS_DOMAIN_ID. To do this, modify the ~/.bashrc file and change the ROS_DOMAIN_ID value to match the car's. Save and exit the file, then enter the command source ~/.bashrc to refresh the environment variables.
- To verify distributed communication between the two, run the driver program on the board, then enter ros2 node list on the virtual machine. If the underlying data topic appears, the two devices are communicating.
The Orin board can be run directly on the board.
3. Program Startup
For Raspberry Pi and Jetson-Nano boards, you need to enter the Docker container first. For RDKX5 and Orin controllers, this is not necessary.
Enter the Docker container (see [Docker course] --- [4. Docker Startup Script] for steps).
All the following commands must be executed within the same Docker container (see [Docker course] --- [3. Docker Submission and Multi-Terminal Access] for steps).
First, enter the following command in the car terminal to start the depth camera.
xxxxxxxxxxros2 launch ascamera hp60c.launch.py

Enter the following command in the virtual machine terminal for rviz visualization.
xxxxxxxxxxros2 launch yahboomcar_nav display_rtabmap_nav_launch.py

Wait for RTAB navigation to start.
Enter the following command in the terminal to start the chassis and mapping.
xxxxxxxxxxros2 launch yahboomcar_nav navigation_rtabmap_launch.py

At the same time, rviz will display the map.

- From rviz, you can see that the robot automatically estimates its initial position, eliminating the need for manual position initialization.
- If the car's initial position is significantly off, use the [2D Pose Estimate] tool in the RVIZ toolbar to provide an approximate position for quick positioning.

Enter the following command in the terminal to start navigation2:
xxxxxxxxxxros2 launch yahboomcar_nav rtabmap_nav_launch.py
After everything is successfully launched, an expansion area will appear, as shown below.

Then use the [Nav2 Goal] tool in RVIZ to specify a target point for the car, and it will navigate to that point.

Note: If navigation performance is poor, consider building a map in a closed environment. This is because the robot relies on deep visual odometry, and the robot's straight line is not very straight. When the robot moves forward or turns, the deep visual odometry will deviate. This will eventually lead to accumulated errors and drift. A closed environment will provide better performance, or you can increase the mapping time to record more points for each feature point on the map.
4. View the Node Communication Graph
In the terminal, enter:
xxxxxxxxxxros2 run rqt_graph rqt_graph
If the map does not display initially, select [Nodes/Topics (all)] and click the refresh button in the upper left corner.

5. Node Details for rtabmap Navigation
View RGB Image Synchronization Node Information
xxxxxxxxxxros2 node info /rgbd_sync

View the /rtabmap node
xxxxxxxxxxros2 node info /rtabmap
x/rtabmap Subscribers /global_posegeometry_msgs/msg/PoseWithCovarianceStamped /goalgeometry_msgs/msg/PoseStamped /goal_nodertabmap_msgs/msg/Goal /gps/fixsensor_msgs/msg/NavSatFix /imusensor_msgs/msg/Imu /initialposegeometry_msgs/msg/PoseWithCovarianceStamped /landmark_detectionrtabmap_msgs/msg/LandmarkDetection /landmark_detectionsrtabmap_msgs/msg/LandmarkDetections /parameter_eventsrcl_interfaces/msg/ParameterEvent /rgbd_imagertabmap_msgs/msg/RGBDImage /rtabmap/republish_node_datastd_msgs/msg/Int32MultiArray /scansensor_msgs/msg/LaserScan /user_data_asyncrtabmap_msgs/msg/UserData Publishers /cloud_groundsensor_msgs/msg/PointCloud2 /cloud_mapsensor_msgs/msg/PointCloud2 /cloud_obstaclessensor_msgs/msg/PointCloud2 /diagnosticsdiagnostic_msgs/msg/DiagnosticArray /global_pathnav_msgs/msg/Path /global_path_nodesrtabmap_msgs/msg/Path /goal_outgeometry_msgs/msg/PoseStamped /goal_reachedstd_msgs/msg/Bool /grid_prob_mapnav_msgs/msg/OccupancyGrid /infortabmap_msgs/msg/Info /labelsvisualization_msgs/msg/MarkerArray /landmarksgeometry_msgs/msg/PoseArray /local_grid_emptysensor_msgs/msg/PointCloud2 /local_grid_groundsensor_msgs/msg/PointCloud2 /local_grid_obstaclesensor_msgs/msg/PointCloud2 /local_pathnav_msgs/msg/Path /local_path_nodesrtabmap_msgs/msg/Path /localization_posegeometry_msgs/msg/PoseWithCovarianceStamped /mapnav_msgs/msg/OccupancyGrid /mapDatartabmap_msgs/msg/MapData /mapGraphrtabmap_msgs/msg/MapGraph /mapOdomCachertabmap_msgs/msg/MapGraph /mapPathnav_msgs/msg/Path /octomap_binaryoctomap_msgs/msg/Octomap /octomap_empty_spacesensor_msgs/msg/PointCloud2 /octomap_fulloctomap_msgs/msg/Octomap /octomap_global_frontier_spacesensor_msgs/msg/PointCloud2 /octomap_gridnav_msgs/msg/OccupancyGrid /octomap_groundsensor_msgs/msg/PointCloud2 /octomap_obstaclessensor_msgs/msg/PointCloud2 /octomap_occupied_spacesensor_msgs/msg/PointCloud2 /parameter_eventsrcl_interfaces/msg/ParameterEvent /rosoutrcl_interfaces/msg/Log /tftf2_msgs/msg/TFMessage Service Servers /rtabmap/add_linkrtabmap_msgs/srv/AddLink /rtabmap/backupstd_srvs/srv/Empty /rtabmap/cancel_goalstd_srvs/srv/Empty /rtabmap/cleanup_local_gridsrtabmap_msgs/srv/CleanupLocalGrids /rtabmap/describe_parametersrcl_interfaces/srv/DescribeParameters /rtabmap/detect_more_loop_closuresrtabmap_msgs/srv/DetectMoreLoopClosures /rtabmap/get_mapnav_msgs/srv/GetMap /rtabmap/get_map_datartabmap_msgs/srv/GetMap /rtabmap/get_map_data2rtabmap_msgs/srv/GetMap2 /rtabmap/get_node_datartabmap_msgs/srv/GetNodeData /rtabmap/get_nodes_in_radiusrtabmap_msgs/srv/GetNodesInRadius /rtabmap/get_parameter_typesrcl_interfaces/srv/GetParameterTypes /rtabmap/get_parametersrcl_interfaces/srv/GetParameters /rtabmap/get_plannav_msgs/srv/GetPlan /rtabmap/get_plan_nodesrtabmap_msgs/srv/GetPlan /rtabmap/get_prob_mapnav_msgs/srv/GetMap /rtabmap/global_bundle_adjustmentrtabmap_msgs/srv/GlobalBundleAdjustment /rtabmap/list_labelsrtabmap_msgs/srv/ListLabels /rtabmap/list_parametersrcl_interfaces/srv/ListParameters /rtabmap/load_databasertabmap_msgs/srv/LoadDatabase /rtabmap/log_debugstd_srvs/srv/Empty /rtabmap/log_errorstd_srvs/srv/Empty /rtabmap/log_infostd_srvs/srv/Empty /rtabmap/log_warningstd_srvs/srv/Empty /rtabmap/octomap_binaryoctomap_msgs/srv/GetOctomap /rtabmap/octomap_fulloctomap_msgs/srv/GetOctomap /rtabmap/pausestd_srvs/srv/Empty /rtabmap/publish_maprtabmap_msgs/srv/PublishMap /rtabmap/remove_labelrtabmap_msgs/srv/RemoveLabel /rtabmap/resetstd_srvs/srv/Empty /rtabmap/resumestd_srvs/srv/Empty /rtabmap/set_goalrtabmap_msgs/srv/SetGoal /rtabmap/set_labelrtabmap_msgs/srv/SetLabel /rtabmap/set_mode_localizationstd_srvs/srv/Empty /rtabmap/set_mode_mappingstd_srvs/srv/Empty /rtabmap/set_parametersrcl_interfaces/srv/SetParameters /rtabmap/set_parameters_atomicallyrcl_interfaces/srv/SetParametersAtomically /rtabmap/trigger_new_mapstd_srvs/srv/Empty /rtabmap/update_parametersstd_srvs/srv/Empty Service Clients /rtabmap/describe_parametersrcl_interfaces/srv/DescribeParameters /rtabmap/get_parameter_typesrcl_interfaces/srv/GetParameterTypes /rtabmap/get_parametersrcl_interfaces/srv/GetParameters /rtabmap/list_parametersrcl_interfaces/srv/ListParameters /rtabmap/set_parametersrcl_interfaces/srv/SetParameters /rtabmap/set_parameters_atomicallyrcl_interfaces/srv/SetParametersAtomically Action Servers Action Clients