JetRacer ROS AI Kit Advanced Tutorial I: SLAM Lidar Mapping

From Waveshare Wiki
Revision as of 07:54, 7 November 2022 by Eng52 (talk | contribs) (Created page with "==Enable Slam Mapping Node== *First, turn on the radar to keep it rotating normally. Please run the following command to start the lidar node on the robot.<br/> [Note: The cha...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Enable Slam Mapping Node

  • First, turn on the radar to keep it rotating normally. Please run the following command to start the lidar node on the robot.

[Note: The chassis node and radar node will be enabled by default when starting the slam mapping node, so please close the robot chassis node and radar node first to avoid conflicts and errors when starting the slam mapping node.]

roslaunch jetbot_pro slam.launch #The mapping algorithm uses gmapping by default

SLAM Lidar Mapping01.png

  • Run the following command in the virtual machine to start the rviz image tool to view. This startup file also starts the gamepad remote control node, so you need to connect the gamepad receiving area to the virtual machine before running the command.
  • After rviz is started, it will display radar information, camera images, map data, TF coordinates and other information. Use a gamepad to control mechanical movement to scan the map.
roslaunch jetbot_pro view_slam.launch #Display map

SLAM Lidar Mapping02.png

  • If the following error occurs when displaying the map, please check whether the remote controller is connected, where /dev/input/js0 is the remote controller device.

SLAM Lidar Mapping03.png

Save the Map Document

  • After scanning the map, open a new terminal in the robot and run the following command to save the constructed map file.
cd ~/catkin_ws/src/jetbot_pro/maps
rosrun map_server map_saver -f mymap

SLAM Lidar Mapping04.png

  • Run the ls command to view the saved map information.
ls

SLAM Lidar Mapping05.png

  • Among them: mymap.pgm is the map data, mymap.yaml is the map information, and savemap.sh is the save map script. So you can also run this script to save the map.
cd ~/catkin_ws/src/jetbot_pro/maps && ./savemap.sh

Implementation of a variety of mapping algorithms

  • The program supports four mapping algorithms: gmapping, hector, karto, and cartographer. By default, the gmapping algorithm is used, and the corresponding mapping algorithm can also be selected through the map_type parameter.
  • The following is the command input to select different map_type parameters.
roslaunch jetbot_pro slam.launch map_type:=gmapping #gmapping algorithm (default)
roslaunch jetbot_pro slam.launch map_type:=hector #hector algorithm
roslaunch jetbot_pro slam.launch map_type:=karto #karto algorithm
roslaunch jetbot_pro slam.launch map_type:=cartographer #cartographer algorithm
  • On the virtual machine side, using the algorithms gmapping, hector, and karto, you can run the following commands to display the map
roslaunch jetbot_pro view_slam.launch #Display map.
  • If you use the algorithm cartographer, the configuration of rviz is different, you need to use the following command to display the map.
roslaunch jetbot_pro view_slam.launch map_type:=cartographer #Display map
  • Hector algorithm mapping effect.

SLAM Lidar Mapping06.png

  • Karto algorithm mapping effect>

SLAM Lidar Mapping07.png

  • Cartographer algorithm mapping effect. The green points in the figure are point cloud data instead of radar data, and the blue points are the moving paths of the car.

SLAM Lidar Mapping08.png

  • Note: When using the algorithm gmapping, hector, karto to build a map, you can save the map directly through the map_server command; after the cartographer algorithm builds a map, you need to convert the pbstream to map before saving, that is, we can use the following script to save the map.
cd ~/catkin_ws/src/jetbot_pro/maps && ./carto_savemap.sh