gmapping mapping algorithm6.1. Program Function Description6.2. Introduction to Gmapping6.3, Program code reference path6.4, Program startup6.4.1, Map creation6.4.2, map saving6.4.3, view the topic communication node graph6.4.4, view TF tree
After the programs on the virtual machine and the car are started, the car is controlled by the handle or keyboard. The car will use the radar scanning data during the movement, use the gmapping algorithm to build a map, and save the map after the construction is completed. This process is visualized in rviz.
wiki: http://wiki.ros.org/gmapping/
ros2 gmapping: https://github.com/Project-MANAS/slam_gmapping
Advantages: Gmapping can build indoor maps in real time, and the amount of calculation required to build small scene maps is small and the accuracy is high.
Disadvantages: As the scene increases, the number of particles required increases, because each particle carries a map, so the memory and amount of calculation required to build a large map will increase. Therefore, it is not suitable for building large scene maps. And there is no loop detection, so the map may be misaligned when the loop is closed. Although increasing the number of particles can make the map closed, it comes at the cost of increasing the amount of calculation and memory.
After SSH connects to the car, the location of the function source code is,
/home/sunrise/yahboomcar_ws/src/yahboomcar_nav/launch/map_gmapping_launch.py
The source code of the virtual machine is located at,
xxxxxxxxxx
/home/yahboom/yahboomcar_ws/src/yahboomcar_rviz/launch/yahboomcar_mapping_launch.py
Open the virtual machine terminal and enter,
xxxxxxxxxx
ros2 launch yahboomcar_rviz yahboomcar_mapping_launch.py
After SSH connects to the car, input in the terminal,
xxxxxxxxxx
ros2 launch yahboomcar_nav map_gmapping_launch.py
Unlock the [L1] key on the handle to control the movement of the car. If you do not use the handle, you can use the keyboard to control, input in the SSH car terminal,
xxxxxxxxxx
ros2 run yahboomcar_ctrl yahboom_keyboard
[Slowly move the car] to start building the map until the complete map is built.
Note: When building a map, the slower the speed, the better the effect (especially the slower the rotation speed). If the speed is too fast, the effect will be very poor.
In addition, the path of gmapping related configuration parameters is,
xxxxxxxxxx
/home/sunrise/yahboomcar_ws/src/slam_gmapping/params/slam_gmapping.yaml
You can modify it as needed, compile and run.
Input in the car terminal,
xxxxxxxxxx
ros2 launch yahboomcar_nav save_map_launch.py
The map saving path is as follows:
xxxxxxxxxx
/home/sunrise/yahboomcar_ws/src/yahboomcar_nav/maps/yahboom_map
Includes a .pgm image and a .yaml file. Among them, the .yaml file content is as follows:
xxxxxxxxxx
image yahboom_map.pgm
mode trinary
resolution0.05
origin -10 -10 0
negate0
occupied_thresh0.65
free_thresh0.25
Parameter analysis:
Virtual machine terminal input,
xxxxxxxxxx
ros2 run rqt_graph rqt_graph
Open the virtual machine terminal, input,
xxxxxxxxxx
#Save tf tree
ros2 run tf2_tools view_frames
#View tf tree
evince frames.pdf