7. Hector mapping algorithm

hector_slam: http://wiki.ros.org/hector_slam

hector_slam/Tutorials: http://wiki.ros.org/hector_slam/Tutorials/SettingUpForYourRobot

hector_mapping: http://wiki.ros.org/hector_mapping

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

7.1. Introduction

Features: hector_slam does not need to subscribe to odometry/odom messages. It uses the Gauss-Newton method and directly uses lidar to estimate odometry information. However, when the robot is fast, slipping will occur, causing deviations in the mapping effect and placing high demands on sensors. When building a map, set the car's rotation speed as low as possible.

There is no method to use the odom coordinate system, taken from Wiki.

image-20220224144154123

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

7.2.1. Start

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

Mapping command (robot side)

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

image-20240408144126098

Turn on the visual interface (virtual machine side)

image-20220224144503635

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

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

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

7.3. Topics and services

Topic SubscriptionTypeDescription
scansensor_msgs/LaserScanDepth data of lidar scan
syscommandstd_msgs/StringSystem command. If the string equals "reset", the map and robot pose are reset to the initial state
Topic PostTypeDescription
map_metadatanav_msgs/MapMetaDataPublish map Metadata
mapnav_msgs/OccupancyGridPublish map raster data
slam_out_posegeometry_msgs/PoseStampedCovariance-free robot pose estimation
poseupdategeometry_msgs
/PoseWithCovarianceStamped
Robot pose estimation with Gaussian uncertainty estimation
ServiceTypeDescription
dynamic_mapnav_msgs/GetMapGet map data
reset_mapstd_srvs/TriggerCall this service to reset the map, and hector will create a brand new map from scratch. Note that this will not restart the robot's pose, it will restart from the last recorded pose.
pause_mappingstd_srvs/SetBoolCall this service to stop/start processing laser scans.
restart_mapping_with_new_posehector_mapping/ResetMappingCall this service to reset the map, robot's pose, and resume the map (if paused)

Node view

image-20220224144503635

7.4. Configuration parameters

ParametersTypeDefault valueDescription
~base_frameString"base_link"Robot base coordinate system, used for positioning and laser scanning data transformation
~map_frameString"map"The coordinate system of the map
~odom_framestring"odom"Odometer coordinate system (essentially the coordinate system pointed to by map)
~map_resolutionDouble0.025(m)Map resolution, edge length of grid cells
~map_sizeInt1024The size of the map
~map_start_xdouble0.5/The position of the origin of map [0.0, 1.0] on the x-axis relative to the grid map
~map_start_ydouble0.5/The position of the origin of /map [0.0, 1.0] on the y-axis relative to the grid map
~map_update_distance_threshdouble0.4(m)The threshold for map update, which is calculated from the first update on the map until the straight distance reaches this parameter value and is updated again
~map_update_angle_threshdouble0.9(rad)The threshold for map update, starting from the first update on the map and updating again after the rotation reaches this parameter value
~map_pub_perioddouble2.0Map release cycle
~map_multi_res_levelsint3Map multi-resolution grid levels
~update_factor_freedouble0.4Used to update the map of free cells, the range is [0.0, 1.0]
~update_factor_occupieddouble0.9Used to update the map of occupied units, the range is [0.0, 1.0]
~laser_min_distdouble0.4(m)The minimum distance of laser scanning points. Scanning points smaller than this value will be ignored
~laser_max_distdouble30.0(m)The maximum distance of laser scanning points. Scanning points smaller than this value will be ignored
~laser_z_min_valuedouble-1.0(m)Minimum height relative to the lidar, scan points below this value will be ignored
~laser_z_max_valuedouble1.0(m)The maximum height relative to the lidar, scan points above this value will be ignored
~pub_map_odom_transformbooltrueWhether to publish the coordinate transformation between map and odom
~output_timingboolfalseProcess the output timing information of each laser scan through ROS_INFO
~scan_subscribe_queue_sizeint5Queue size for scan subscribers
~pub_map_scanmatch_transformbooltrueWhether to publish the coordinate transformation between scanmatcher and map
~tf_map_scanmatch_transform_frame_nameString"scanmatcher_frame"The coordinate system name of scanmatcher

7.5, TF transformation

Required TF transformationDescription
laser-->base_linkUsually a fixed value, the transformation between the lidar coordinate system and the base coordinate system, generally published by robot_state_publisher or static_transform_publisher
Released TF TransformDescription
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-20220224144503635