8.karto mapping algorithm

karto : http://wiki.ros.org/slam_karto

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

8.1 Introduction

Karto is a 2D laser SLAM solution based on sparse graph optimization with loop closure detection. The graph optimization method uses the mean value of the graph to represent the map, and each node represents a position point of the robot trajectory and a sensor measurement data set. Karto uses the spa(karto_slam) or g2o(nav2d) optimization library, and the front-end and back-end are single-threaded.

The ROS version of Karto_SLAM, which employs the Spare Pose Adjustment(SPA) related to scan matching and loop closure detection. The more landmarks there are, the greater the memory requirements. However, the graph optimization method has greater advantages in mapping compared to other methods in a large environment, because it only contains the robot pose of the point, and then the map is obtained after the pose is obtained.

overall program framework

img

8.2 Use

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

According to different models, you only need to set the purchased model in [.bashrc], X1(ordinary four-wheel drive) X3(Mike wheel) X3plus(Mike wheel mechanical arm) R2(Ackerman differential) and so on. Section takes X3 as an example

Open the [.bashrc] file

Find the [ROBOT_TYPE] parameter and modify the corresponding model

8.2.1 Start

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

Mapping command(robot side)

Open the visual interface(virtual machine side)

image-20220224150211979

The gap at the back of the robot is due to the occlusion of the installation position of the display screen, so a certain range of Lidar data is shielded. The shielding range can be adjusted or not shielded according to the actual situation. For details, see [01. Lidar Basic Course].

8.2.2 Control the robot

Make the robot walk all over the area to be built, and the map is as closed as possible.

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

8.2.3 Map save

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

map.yaml

Parameter parsing:

8.3 Topics and Services

Topic subscriptiontypedescribe
scansensor_msgs/LaserScanDepth data from lidar scans
tftf/tfMessageUsed to convert between lidar coordinate system, base coordinate system, and odometer coordinate system
Topic releasetypedescribe
map_metadatanav_msgs/MapMetaDataPublish map Meta data
mapnav_msgs/OccupancyGridPublish map raster data
visualization_marker_arrayvisualisation_msgs/MarkerArrayPost pose diagram
Servetypedescribe
dynamic_mapnav_msgs/GetMapGet map data

Node view

image-20220224150211979

8.4 configuration parameters

parametertypeDefaultsillustrate
~base_framestring"base_link"Robot base coordinate system
~map_framestring"map"map coordinate system
~odom_framestring"odom"Odometer Coordinate System
~throttle_scansint1Process 1 every so many scans(set it to a higher number to skip more scans)
~map_update_intervalfloat5.0The interval in seconds between map updates. Lowering this number updates the occupancy grid more frequently, but increases the computational load.
~resolutionfloat0.05Map resolution(meters per occupied grid block)
~deltafloat0.05Map resolution(meters per occupied grid block). Same as resolution. Defined for compatibility with gmapping parameter names.
~transform_publish_periodfloat0.05The interval(in seconds) between transition publications.
use_scan_matchingbooltrueWhether to use the scan matching algorithm, generally set to true, the mapper algorithm can correct the noise and error of the odometer and the laser. In some simulation environments with accurate sensor data, the scan matching algorithm will get worse results(because of the use of Gaussian blur, which reduces the observation confidence of high-precision sensors), it is recommended to close(add noise to the simulation environment).
use_scan_barycenterbooltrueUse the centroids of the scan endpoints to define the distance between scans.
minimum_travel_distancedouble0.2Sets the minimum travel between scans.
minimum_travel_headingdoubledeg2rad(10) = 0.087266461Sets the minimum angle between scans.
scan_buffer_sizeint70Set the length of ScanBuffer, approximately equal to scan_buffer_maximum_scan_distance/minimum_travel_distance
scan_buffer_maximum_scan_distancedouble20.0Setting the maximum length of ScanBuffer is similar to Size
link_match_minimum_response_finedouble0.8Set minimum response threshold for minimum scans connections
link_scan_minimum_distancedouble10.0Set the maximum distance of scans between two connections. If it is greater than this value, the response threshold of the two will not be considered.
loop_search_maximum_distancedouble4.0Loopback detection maximum distance. Scans less than this distance from the current position will be considered matched loop closures.
do_loop_closingbooltrueWhether to enable loopback detection
loop_match_minimum_chain_sizeint10Loop detection minimum chain size
loop_match_maximum_variance_coarsedoublemath::Square(0.4)=0.16The maximum covariance value of rough matching during loopback matching, if it is less than this value, it is considered a feasible solution
loop_match_minimum_response_coarsedouble0.8The minimum response of coarse matching during loopback matching. If the response value is greater than this value, coarse-precision loopback optimization will start.
loop_match_minimum_response_finedouble0.8The loopback matches the minimum response threshold, and if it is greater than this value, the high-precision starts
parametertypeDefaultsillustrate
correlation_search_space_dimensiondouble0.3Set the search range size of the Correlation Grid
correlation_search_space_resolutiondouble0.01Set the resolution of the Correlation Grid
correlation_search_space_smear_deviationdouble0.03Set the Correlation Grid blur level
parametertypeDefaultsillustrate
loop_search_space_dimensiondouble8.0Loopback detection space range size
loop_search_space_resolutiondouble0.05Loop Closure Detection Spatial Resolution
loop_search_space_smear_deviationdouble0.03Loop closure detection blur level
parametertypeDefaultsillustrate
distance_variance_penaltydoublesqrt(0.3)=0.09(less than 1.0)Compensation factor for odometer during scan-matching
angle_variance_penaltydoublesqrt(deg2rad(20))=0.17453292Compensation coefficient for angle during scan-matching
fine_search_angle_offsetdoubledeg2rad(0.2) = 0.0017453292Refine search angle range
coarse_search_angle_offsetdoubledeg2rad(20) = 0.17453292Rough search angle range
coarse_angle_resolutiondoubledeg2rad(2) = 0.017453292Coarse search angle resolution
minimum_angle_penaltydouble0.9Minimum angle penalty
minimum_distance_penaltydouble0.5minimum distance penalty
use_response_expansionboolfalseWhether to increase the search scope if no good matches are found

8.5 TF transformation

Required TF Transformdescribe
laser-->base_linkUsually a fixed value, the transformation between the lidar coordinate system and the base coordinate system is generally published by robot_state_publisher or static_transform_publisher
base_link-->odomThe transformation between the map coordinate system and the robot's odometer coordinate system to estimate the robot's pose in the map
Published TF Transformdescribe
map-->odomThe current estimate of the robot pose within the map frame(only provided if parameter "pub_map_odom_transform" is true).

View tf tree

image-20220224150211979