gmapping mapping algorithm

6.1. Program Function Description

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.

6.2. Introduction to Gmapping

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.

1684831254419

6.3, Program code reference path

After SSH connects to the car, the location of the function source code is,

The source code of the virtual machine is located at,

6.4, Program startup

6.4.1, Map creation

Open the virtual machine terminal and enter,

After SSH connects to the car, input in the terminal,

image-20241113175240458

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,

[Slowly move the car] to start building the map until the complete map is built.

image-20241113202151404

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,

You can modify it as needed, compile and run.

6.4.2, map saving

Input in the car terminal,

The map saving path is as follows:

1684831343375

Includes a .pgm image and a .yaml file. Among them, the .yaml file content is as follows:

Parameter analysis:

6.4.3, view the topic communication node graph

Virtual machine terminal input,

1685088327419

6.4.4, view TF tree

Open the virtual machine terminal, input,

1685088121603