11. AMCL adaptive Monte Carlo positioning algorithm

11.1. Introduction

The full English name of amcl is adaptive Monte Carlo localization, which is a probabilistic positioning system for two-dimensional mobile robots. In fact, it is an upgraded version of the Monte Carlo positioning method, using the adaptive KLD method to update particles, and using particle filters to track the robot's posture based on known maps. As currently implemented, this node only works with laser scans and laser maps. It can be extended to handle other sensor data. amcl receives laser-based maps, laser scans, and transformation information, and outputs pose estimates. On startup, amcl initializes its particle filter based on the provided parameters. Note that due to the default settings, if no parameters are set, the initial filter state will be a medium-sized particle cloud centered at (0,0,0).

Monte Carlo

The biggest advantage of Monte Carlo method

Disadvantages of Monte Carlo method

particle filter

-The number of particles represents the probability of something. Through some evaluation method (the possibility of evaluating this thing), the distribution of particles is changed. For example, in robot positioning, for a certain particle A, I think there is a high possibility that this particle is at this coordinate (for example, this coordinate belongs to "this thing" mentioned before), then I will give it a high score. Next time you rearrange the positions of all the particles, arrange more near this position. After a few more rounds of this, the particles will all be concentrated in positions with high probability.

Adaptive Monte Carlo

11.2. Navigation and positioning test

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

Open the [.bashrc] file

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

11.2.1. Start

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

Start the navigation obstacle avoidance function (robot side), set parameters and modify the launch file according to needs.

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

image-20240408144126098

Turn on the visual interface (virtual machine side)

image-20220224163659396

11.2.2. Positioning analysis

image-20220224165031265

The position of amcl in the upper left corner of the navigation frame is to tell the robot where it is.

After opening it, we can see a handful of green particles evenly scattered around the robot. When we move the robot randomly (keyboard or mouse control), all the particles also move with it. Use the position of each particle to simulate a sensor information and compare it with the observed sensor information (usually laser), thereby assigning a probability to each particle. Then the particles are regenerated according to the probability of generation. The higher the probability, the greater the probability of generation. After such iterations, all the particles will slowly converge together, and the exact position of the robot will be calculated.

11.2. Topics and services

Subscription topicTypeDescription
scansensor_msgs/LaserScanlidar data
tftf/tfMessageCoordinate transformation information
initialposegeometry_msgs/PoseWithCovarianceStampedUsed to (re)initialize the mean and covariance of the particle filter.
mapnav_msgs/OccupancyGridAfter setting the use_map_topic parameter, AMCL subscribes to this topic to retrieve maps for laser-based positioning. New features in Navigation 1.4.2.
Post TopicTypeDescription
amcl_posegeometry_msgs/PoseWithCovarianceStatmpedRobot pose estimation in the map, with covariance information
particlecloudgeometry_msgs/PoseArrayCollection of pose estimates maintained by particle filter
tftf/tfMessagePublish conversion from odom to map
ServerTypeDescription
global_localizationstd_stvs/EmptyInitialize global positioning, all particles are randomly scattered in free areas on the map
request_normotion_updatestd_stvs/EmptyPerform updates manually and publish updated particles
set_mapnav_msgs/SetMapService for manually setting new maps and poses.
ClientTypeDescription
static_mapnav_msgs/GetMapamcl calls this service to retrieve a map for laser positioning; enabling prevents retrieval of maps from this service.

View nodes

image-20220224171449094

11.3. Parameter configuration

There are three categories of ROS parameters that can be used to configure amcl nodes: ensemble filters, laser models, and odometry models.

ParametersTypeDefault valueDescription
~min_particlesint100Minimum number of particles allowed
~max_particlesint5000Maximum number of particles allowed
~kld_errdouble0.1Maximum error between the true distribution and the estimated distribution
~kld_zdouble0.99The upper standard normal quantile of (1-p), where p is the probability that the estimated distribution error is less than kld_err
~update_min_ddouble0.2(m)The translation distance required to perform a filter update
~update_min_adoublepi/6.0(rad)The rotational movement required to perform a filter update
~reseample_intervalint2Number of filter updates before resampling
~transform_tolerancedouble0.1(s)The time the transform is issued to indicate that this transform is valid for the future
~recovery_alpha_slowdouble0.0The exponential decay rate of the slow average weight filter, used to decide when to perform recovery operations by adding random poses, 0.0 means disabled
~recovery_alpha_fastdouble0.0The exponential decay rate of the fast average weight filter, used to decide when to perform recovery operations by adding random poses, 0.0 means disabled
~initial_pose_xdouble0.0(m)Initial pose average (x), used to initialize the Gaussian distribution filter
~initial_pose_ydouble0.0(m)Initial pose average (y), used to initialize the Gaussian distribution filter
~initial_pose_adouble0.0(m)Initial pose average (yaw), used to initialize the Gaussian distribution filter
~initial_cov_xxdouble0.5*0.5(m)Initial attitude average (x*x), used to initialize the Gaussian distribution filter
~initial_cov_yydouble0.5*0.5(m)Initial attitude average (y*y), used to initialize the Gaussian distribution filter
~initial_cov_aadouble(pi/12)*(pi/12)(rad)Initial attitude average (yaw*yaw), used to initialize the Gaussian distribution filter
~gui_publish_ratedouble-1.0(Hz)The maximum rate of publishing information during visualization, -1.0 means disabled
~save_pose_ratedouble0.5(Hz)The maximum rate at which pose estimates initial_pose_ and covariance initial_cov_ are stored in the parameter server for subsequent initialization of the filter. -1.0 means disabled
~use_map_topicboolfalseWhen set to true, amcl will subscribe to the map topic instead of receiving the map through a service call
~first_map_onlyboolfalseWhen set to true, amcl will only use the first map it subscribes to, rather than the map received with each update
~selective_resamplingboolfalseWhen set to true, will reduce the resampling rate when not needed and help avoid particle deprivation. Resampling will only occur when the effective number of particles (N_eff=1/(sum(k_i^2))) is less than half of the current number of particles.
ParametersTypeDefault valueDescription
~laser_min_rangedouble-1.0Minimum scan range, set to -1, the minimum usage range reported by lidar.
~laser_max_rangedouble-1.0Maximum scan range, set to -1, the maximum usage range reported by lidar.
~laser_max_beamsint30How many evenly spaced beams to use in each scan when updating the filter
~laser_z_bitdouble0.95Mixing weight for the z_bit part of the model
~laser_z_shortdouble0.1Mixing weights for the z_short part of the model
~laser_z_maxdouble0.05Mixing weights for the z_max part of the model
~laser_z_randdouble0.05Mixing weights for the z_rand part of the model
~laser_sigma_hitdouble0.2(m)The standard deviation of the Gaussian model used in the z_hit part of the model
~laser_lambda_shortdouble0.1Exponential decay parameter for the z_short part of the model
~laser_likelihood_max_distdouble2.0(m)Maximum distance on the map to measure obstacle expansion
~laser_model_typestring"likelihood_field"Model selection, bean, likelihood_field or likelihood_field_prob
ParametersTypeDefault valueDescription
~odom_model_typestring"diff"Model selection, diff, omni, diff-corrected or omni-corrected
~odom_alpha1double0.2Specifies the expected noise in odometry rotation estimates based on the rotational component of robot motion
~odom_alpha2double0.2Specifies the expected noise in odometry rotation estimates based on the translational component of robot motion
~odom_alpha3double0.2Specifies the expected noise in odometry translation estimates based on the translational component of robot motion
~odom_alpha4double0.2Specifies the expected noise in odometry translation estimates based on the rotational component of robot motion
~odom_alpha5double0.2Translation related noise parameter (only used in model omni)
~odom_frame_idstring"odom"Odometer coordinate system
~base_frame_idstring"base_link"The coordinate system of the robot chassis
~global_frame_idstring"map"Coordinate system published by the positioning system
~tf_broadcastbooltrueWhen set to false, amcl will not publish the coordinate system transformation between map and odom

11.4. Coordinate transformation

amcl_localization.png

Compare the two methods Odometry Localization and AMCL Map Localization:

Odometry Localization: The rotation speed of the wheel can be known through the encoder feedback of the motor, the current wheel speed can be known according to the radius of the wheel, the overall moving speed of the robot can be obtained according to the forward kinematics model, and the movement can be known by integrating according to time. total mileage.

AMCL Map Localization: In amcl, the pose information of base_frame corresponding to map_frame has been obtained through particle filter positioning. However, in order to ensure that base_frame has only one parent node, this conversion is not directly released, because the parent node of base_frame is already odom_frame. Then amcl can only publish the conversion from map_frame to odom_frame. Another advantage of this is that we can get the cumulative error of odom.

We have always said that the distance measurement information obtained by the wheel odometer will have a cumulative error, which is similar to a car skidding. If only the wheel odometer is used to calculate the moving distance, it willError:

1.gif

For example: the robot walks forward in a straight line, and the result obtained from the wheel odometer should be that it has walked 1 meter, so the distance to odom_frame should be 1 meter. However, due to slipping on the spot, the robot actually found that it did not move at all through amcl positioning, then amcl needs to publish the conversion from map_frame to odom_frame to remove this 1-meter error, so that the entire tf tree can be maintained normally.

The conversion relationship between coordinates.

image-20220224171032366

As can be seen from the above figure, the coordinate conversion from map to odom is completed by the amcl node.