Welcome to ROSMASTER A1 repository
12.RTAB-Map navigation
RTAB-Map Navigation
1. Content Description
This section explains how to implement RTAB-Map navigation by combining a vehicle chassis, LiDAR, depth camera, and Navigation2.
This section requires entering commands in the terminal. The appropriate terminal 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 lesson in the terminal. For instructions on entering the Docker container from the host computer, refer to [01. Robot Configuration and Operation Guide] -- [5.Enter Docker (For JETSON Nano and RPi 5)].
For Orin and RDK boards, simply open the terminal and enter the commands mentioned in this lesson.
2. Preparation
Due to performance limitations, Raspberry Pi 5 and Jetson Nano cannot smoothly run the RTAB-Map algorithm within the motherboard's Docker container. Therefore, a virtual machine is needed to assist in implementation. For the vehicle and the virtual machine to achieve distributed communication, the following two steps are required:
- They must be on the same local area network (LAN). The simplest way to achieve this is to connect to the same Wi-Fi network.
- Their ROS_DOMAIN_IDs must be consistent. The default ROS_DOMAIN_ID for both the vehicle and the virtual machine is 30. If they are different, the virtual machine's ROS_DOMAIN_ID needs to be modified. Modify the
~/.bashrcfile, change the ROS_DOMAIN_ID value to match the vehicle's, save and exit, then enter the commandsource ~/.bashrcto refresh the environment variables. - Check if distributed communication is achieved. Run the driver program on the motherboard, then enter
ros2 node liston the virtual machine. If the underlying data lists, communication between the two is successful.
Orin motherboards can run directly on the motherboard, and if RDK doesn't run smoothly, it can be run on a virtual machine for visualization.
3. Program Startup
For PI5/JETSON NANO controllers, you need to enter a Docker container first; for RDK X5 and Orin boards, this is not required.
Entering a Docker container (see the Docker course for steps: 4. Docker Startup Script).
All commands below must be executed within the same Docker container (see the Docker course for steps: 3. Docker Commit and Multi-Terminal Entry).
First, enter the following command in the vehicle 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 camera.
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