6. gmapping mapping algorithm

Gmapping: http://wiki.ros.org/gmapping/

map_server: https://wiki.ros.org/map_server

6.1. Introduction

Advantages:Gmapping can construct indoor maps in real time. The amount of calculation required to construct small scene maps is small and the accuracy is high.

Disadvantages: As the scene grows, the number of particles required increases because each particle carries a map, so the amount of memory and computation required when building a large map increases. 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 close the map, it comes at the expense of increased calculations and memory.

image-20220224141102272

6.2. Use

Note: When building a map, the slower the speed, the better the effect (note that the rotation speed should be slower). If the speed is too fast, the effect will be poor.

According to different models, you only need to set the purchased model in [.bashrc], X1 (normal four-wheel drive) X3 (Mailun) Take X3 as an example

Open the [.bashrc] file

Find the [ROBOT_TYPE] parameters and modify the corresponding car model

6.2.1. Start

Start the command (robot side). For the convenience of operation, this section takes [mono + laser + yahboomcar] as an example.

<PI5 needs to open another terminal to enter the same docker container

image-20240408144126098

Mapping command (robot side)

Turn on the visual interface (virtual machine side)

image-20220224143306896

The gap at the back of the robot is due to the obstruction caused by the installation position of the display screen, so a certain range of radar data is blocked. The shielding range can be adjusted, or it can not be blocked according to the actual situation. For specific operations, see [01. Radar Basic Course].

6.2.2. Controlling the robot

Make the robot cover the area to be mapped and the map should be as closed as possible.

There may be some scattered points during the mapping process. If the mapping environment is well closed, relatively regular, and the movement is slow, the scattering phenomenon will be much smaller.

6.2.3. Map saving

The map will be saved to the ~/yahboomcar_ws/src/yahboomcar_nav/maps/ folder, a pgm image and a yaml file.

map.yaml

Parameter analysis:

6.2. Topics and services

Subscription topicTypeDescription
tftf/tfMessageUsed for conversion between lidar coordinate system, base coordinate system, and odometer coordinate system
scansensor_msgs/LaserScanLidar scan data
Post TopicTypeDescription
map_metadatanav_msgs/MapMetaDataPublish map Metadata
mapnav_msgs/OccupancyGridPublish map raster data
~entropystd_msgs/Float64Publish an estimate of the entropy of the robot pose distribution
ServiceTypeDescription
dynamic_mapnav_msgs/GetMapGet map data

Node view

image-20220224141102272

6.3. Configuration parameters

ParametersTypeDefault valueDescription
~throttle_scansint1Each time this number of frames of laser data is received, only one frame of data is processed. By default, each frame of data is processed
~base_framestring"base_link"Robot base coordinate system
~map_framestring"map"Map coordinate system
~odom_framestring"odom"Odometer coordinate system
~map_update_intervalfloat5.0Map update frequency, the lower the value, the greater the computational load
~maxUrangefloat80.0The maximum range that the laser can detect
~sigmafloat0.05standard deviation of endpoint matches
~kernelSizeint1Search in the corresponding kernel
~lstepfloat0.05Optimization step size during translation
~astepfloat0.05Optimization step size during rotation
~iterationsint5Number of iterations to scan for matches
~lsigmafloat0.075Laser standard deviation of likelihood calculation
~ogainfloat3.0Used to smooth the resampling effect during likelihood calculation
~lskipint0Number of beams skipped per scan
~minimumScorefloat0The minimum value of scan matching results. When using a laser scanner with a limited range (e.g. 5m), jumping in large open spaces can be avoided
~srrfloat0.1Translation function (rho/rho), odometry error during translation
~srtfloat0.2rotation function (rho/theta), odometry error in translation
~strfloat0.1Translation function (theta/rho), odometry error when rotating
~sttfloat0.2Rotation function (theta/theta), odometry error when rotating
~linearUpdatefloat1.0Process the laser scanning data every time the robot translates this distance
~angularUpdatefloat0.5The robot processes laser scanning data every time it rotates this distance
~temporalUpdatefloat-1.0Process a scan if the latest scan is processed slower than the update. Turn off time-based updates when this value is negative
~resampleThresholdfloat0.5Neff-based resampling threshold
~particlesint30Number of particles in the filter
~xminfloat-100.0Initial minimum size of map in x direction
~yminfloat-100.0The initial minimum size of the map in the y direction
~xmaxfloat100.0The initial maximum size of the map in the x direction
~ymaxfloat100.0The initial maximum size of the map in the y direction
~deltafloat0.05map resolution
~llsamplerangefloat0.01Translation sampling distance for likelihood calculation
~llsamplestepfloat0.01translation sampling step for likelihood calculation
~lasamplerangefloat0.005Rotated sampling distance for likelihood calculation
~lasamplestepfloat0.005Rotation sampling step size for likelihood calculation
~transform_publish_periodfloat0.05TF transform publishing time interval
~occ_threhfloat0.25Threshold for raster map occupancy
~maxRange(float)float-The maximum range of the sensor

6.4, TF transformation

Required TF transformationDescription
laser-->base_linkThe transformation between the laser radar coordinate system and the base coordinate system is generally published by robot_state_publisher or static_transform_publisher
base_link-->odomTransformation between the map coordinate system and the robot odometer coordinate system, estimating the robot's pose in the map
Released TF TransformDescription
map-->odomTransformation between the map coordinate system and the robot's odometry coordinate system, estimating the robot's pose in the map

View tf tree

image-20220224141102272