SLAM Mapping

Aus HSHL Mechatronik
Zur Navigation springen Zur Suche springen
Danach kann dann eine Karte des Raumes erstellt werden. Hierfür kann dem Tutorial SLAM Lidar Mapping gefolgt werden, und es können vier verschiedene Mapping-Algorithmen ausprobiert werden.
Hier bei ist allerdings zu beachten das der im Tutorial gegebene Save Befehl abgeändert werden muss. Das jetbot_pro im Befehl muss auf jetracer_ros geändert werden, sodass der Befehle "cd catkin_ws/src/jetracer_ros/maps" lautet.

Slam Karten Knoten aktivieren

  • 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

[]

  • 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

[]

  • 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.

[]

Karte abspeichern

  • 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

[]

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

[]

  • 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

Verschiedene Algorithmen

  • 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.

[]

  • Karto algorithm mapping effect

[]

  • 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.

[]

  • 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