6. gmapping graph building algorithm6.1 Program function description6.2. Introduction to Gmapping6.3 Program code reference path6.4. Program Startup6.4.1. Build the diagram6.4.2. Map saving6.4.3. View the topic communication node graph6.4.4 View the 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 uses the lidar scanning data during the moving process, uses gmapping algorithm to build a map, and saves the map after construction. 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 calculation required for building small-scene maps is small and the precision is high.
Disadvantages: The number of particles required increases as the scene grows, because each particle carries a map, so the memory and computation required to build a large map 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, but at the cost of increasing the amount of computation and memory.
After SSH connection car, the location of the function source code is located at,
/userdata/yahboomcar_ws/src/yahboomcar_nav/launch/map_gmapping_launch.py
The virtual machine side source code is located at,
xxxxxxxxxx
/home/yahboom/dev_ws/src/yahboomcar_rviz/launch/yahboomcar_mapping_launch.py
Open the virtual machine terminal and type,
xxxxxxxxxx
ros2 launch yahboomcar_rviz yahboomcar_mapping_launch.py
After SSH connects to the car, terminal input,
xxxxxxxxxx
ros2 launch yahboomcar_nav map_gmapping_launch.py
Handle [L1] key unlock, control car movement. If you do not use the handle, you can use the keyboard control, the car terminal input,
xxxxxxxxxx
ros2 run yahboomcar_ctrl yahboom_keyboard
【 Slowly move the cart 】 Start to build the map until the complete map is built.
Note: When building the diagram, the slower the better the effect (especially the rotation speed should be slower), the faster the speed, the effect will be poor.
In addition, the paths of gmapping parameters are,
xxxxxxxxxx
/userdata/software/slam_ws/src/slam_gmapping/params/slam_gmapping.yaml
You can modify it according to your needs, compile and run it.
Car terminal input,
xxxxxxxxxx
ros2 launch yahboomcar_nav save_map_launch.py
Map saving path is as follows:,
xxxxxxxxxx
/userdata/yahboomcar_ws/src/yahboomcar_nav/maps
Includes a.pGM image and a.YAML file. The.yaml file contains the following contents:
xxxxxxxxxx
image /userdata/yahboomcar_ws/src/yahboomcar_nav/maps/yahboom_map.pgm
mode trinary
resolution0.05
origin -5.95 -3.26 0
negate0
occupied_thresh0.65
free_thresh0.25
Parameter analysis:
Virtual machine terminal input,
xxxxxxxxxx
ros2 run rqt_graph rqt_graph
To view gmapping node details, enter,
xxxxxxxxxx
ros2 node info /slam_gmapping
Open the virtual machine terminal and type,
xxxxxxxxxx
#保存tf树# Save tf tree
ros2 run tf2_tools view_frames.py
#查看tf树# View tf tree
evince frames.pdf