6. gmapping graph building 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 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.

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

1684831254419

6.3 Program code reference path

After SSH connection car, the location of the function source code is located at,

The virtual machine side source code is located at,

6.4. Program Startup

6.4.1. Build the diagram

Open the virtual machine terminal and type,

After SSH connects to the car, terminal input,

1685523316599

Handle [L1] key unlock, control car movement. If you do not use the handle, you can use the keyboard control, the car terminal input,

【 Slowly move the cart 】 Start to build the map until the complete map is built.

1685523771580

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,

You can modify it according to your needs, compile and run it.

6.4.2. Map saving

Car terminal input,

Map saving path is as follows:,

1684831343375

Includes a.pGM image and a.YAML file. The.yaml file contains the following contents:

Parameter analysis:

6.4.3. View the topic communication node graph

Virtual machine terminal input,

1685088327419

To view gmapping node details, enter,

1685088160681

6.4.4 View the TF tree

Open the virtual machine terminal and type,

1685088121603