6.Lidar mapping

Note: This course uses Rosmaster-X3 as an example. Users need to modify it according to their own motion model.

Different from the handheld lidar mapping content, this mapping adds odom data, so if you use your own motion model, you also need to have odom data.

Function package path: ~/oradar_ws/src/yahboomcar_nav

This section focuses on several commonly used mapping algorithms: gampping、hector、karto、cartographer。

6.1 Start mapping

Input following command:

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.

Keyboard control robot:

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

image-20221130180626862

 

6.2 Save map

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

6.3 Mapping algorithm

6.3.1 gmapping

 

1)Topics and services
Subscribe to topicsTypeDescription
tftf/tfMessageUsed for conversion between lidar coordinate system, base coordinate system and odometer coordinate system
scansensor_msgs/LaserScanLidar scan data
TopicTypeDescription
map_metadatanav_msgs/MapMetaDataPublish map Meta data
mapnav_msgs/OccupancyGridPublish map raster data
~entropystd_msgs/Float64Release the estimation of robot pose distribution entropy
ServiceTypeDescription
dynamic_mapnav_msgs/GetMapGet map data

View node

image-20221130182706710

3)TF Transforms
Required tf Transforms TFDescription
laser-->base_linksually a fixed value, broadcast periodically by a robot_state_publisher, or a tf static_transform_publisher.
base_link-->odomusually provided by the odometry system (e.g., the driver for the mobile base)
Provided tf TransformsDescription
map-->odomthe current estimate of the robot's pose within the map frame

View TF tree

image-20221130182938624

 

4)Website:

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

6.3.2 hector

1)Introduction

Features: hector_slam does not need to subscribe to the odometer/odom message, uses the Gauss Newton method, and directly uses the lidar to estimate the odometer information. However, when the robot speed is faster, it will cause deviations in the mapping effect, and the requirements for sensors are high.

When building maps, adjust the rotation speed of the trolley as low as possible.

2)Topics and services
Topic subscriptionTypeDescription
scansensor_msgs/LaserScanThe laser scan used by the SLAM system.
syscommandstd_msgs/StringSystem command. If the string equals "reset" the map and robot pose are reset to their inital state.
Published TopicsTypeDescription
map_metadatanav_msgs/MapMetaDataGet the map data from this topic
mapnav_msgs/OccupancyGridGet the map data from this topic
slam_out_posegeometry_msgs/PoseStampedThe estimated robot pose without covariance
poseupdategeometry_msgs /PoseWithCovarianceStampedThe estimated robot pose with an gaussian estimate of uncertainty
ServicesTypeDescription
dynamic_mapnav_msgs/GetMapCall this service to get the map data.
reset_mapstd_srvs/TriggerCall this service to reset the map, and hector will start a whole new map from scratch. Notice that this doesn't restart the robot's pose, and 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, the robot's pose, and resume mapping (if paused)

View nodes

image-20221201110343916

View TF tree

image-20221201110458180

3)TF Transforms
Required tf TransformsDescription
laser-->base_linkusually a fixed value, broadcast periodically by a robot_state_publisher, or a tf static_transform_publisher.
Provided tf TransformsDescription
map-->odomthe current estimate of the robot's pose within the map frame (only provided if parameter "pub_map_odom_transform" is true).

 

4) Website:

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

6.3.3 karto

1) Introduction

Karto is a 2D laser SLAM solution, which is based on a sparse graph optimization method with closed loop detection. Karto uses the spa (karto_slam) or g2o (nav2d) optimization library, and the front-end and back-end uses a single-threaded process. It uses odom to predict the initial position.

2)Topics and Services
Subscribed TopicsTypeDescription
scansensor_msgs/LaserScanTransforms necessary to relate frames for laser, base, and odometry
tftf/tfMessageLaser scans to create the map from
Published TopicsTypeDescription
map_metadatanav_msgs/MapMetaDataGet the metadata of the map data (resolution, width, height, ...)
mapnav_msgs/OccupancyGridGet the map data from this topic, which is latched, and updated periodically
visualization_marker_arrayvisualisation_msgs / MarkerArrayGet the pose graph from this topic, which is updated periodically
Published TopicsTypeDescription
dynamic_mapnav_msgs/GetMapCall this service to get the map data
3)Parameters

View node

image-20221201120250507

 

3) TF Transforms
Required tf TransformsDescription
laser-->base_linkusually a fixed value, broadcast periodically by a robot_state_publisher, or a tf static_transform_publisher.
base_link-->odomusually provided by the odometry system (e.g., the driver for the mobile base)
Provided tf TransformsTFDescription
map-->odomthe current estimate of the robot's pose within the map frame

####

View TF tree

image-20221201115719801

 

Website:

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

6.3.4 cartographer

1)Introduction

Cartographer is a 2D and 3D SLAM (simultaneous localization and mapping) library supported by a ROS system open sourced by Google. A graph-building algorithm based on graph optimization (multi-threaded back-end optimization, problem optimization built by cere). Data from multiple sensors (for example, LIDAR, IMU, and camera) can be combined to calculate the position of the sensor simultaneously and map the environment around the sensor.

2)View node

image-20221201121219449

3)View TF transformation

image-20221201121251666

4)Parameters lua file
ParametersDescription
map_frameMap coordinate system
tracking_frameConvert all sensor data to this coordinate system
published_frameThe map points to coordinate system the
odom_frameIf true, the tf tree is map->odom->footprint; if false, the tf tree is map->footprint
provide_odom_frameIf true, the local, non-loop-closed, continuous pose will be published as odom_frame in map_frame
publish_frame_projected_to_2dIf enabled, the published pose will restrict 2D poses
use_odometryWhether to use the odometer, if you use it, you must have odom tf
use_nav_satWhether to use gps
use_landmarksWhether to use landmark
num_laser_scansWhether to use single-line laser data
num_multi_echo_laser_scansWhether to use multi_echo_laser_scans data
num_subdivisions_per_laser_scan1 frame of data is divided into several processings, in generally it is 1
num_point_cloudsWhether to use point cloud data
lookup_transform_timeout_secFind the timeout of tf
submap_publish_period_secTime interval for publishing submap (seconds)
pose_publish_period_secThe time interval for posting pose, when the value is 5e-3, it is 200HZ
trajectory_publish_period_secThe time interval for publishing trajectory markers (trajectory nodes), the value is 30e-3 to 30ms
rangefinder_sampling_ratioFixed sampling frequency of lidar messages
odometry_sampling_ratioFixed sampling frequency of odometer messages
fixed_frame_pose_sampling_ratioFixed sampling frequency of fixed coordinate system messages
imu_sampling_ratioFixed sampling frequency of IMU messages
landmarks_sampling_ratioFixed sampling frequency for road sign messages
5)Website

Cartographer:https://google-cartographer.readthedocs.io/en/latest/

Cartographer ROS:https://google-cartographer-ros.readthedocs.io/en/latest/