7. AMCL adaptive Monte Carlo localization algorithm

7.1. Introduction

amcl stands for adaptive Monte Carlo localization, which is a probabilistic localization system for two-dimensional mobile robots. In fact, it is an upgraded version of the Monte Carlo localization method, using an adaptive KLD method to update particles and a particle filter to track the robot's posture based on a known map. According to the current implementation, this node is only applicable to laser scanning and laser maps. It can be extended to process other sensor data. amcl receives laser-based maps, laser scans, and transformation information, and outputs a posture estimate. At 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 the Monte Carlo method

Disadvantages of the Monte Carlo method

Particle filtering

Adaptive Monte Carlo

7.2, Navigation positioning test

7.2.1, Startup

Turn off the automatic chassis service

Start the driver (robot side).

prints empty and cannot obtain data, the startup is abnormal. Please restart the radar service command.

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

Open the visualization interface

image-20240627150718229

7.2.2, Positioning Analysis

image-20220224165031265

amcl is located in the upper left corner of the navigation frame. Its function 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 move with it. Use the position of each particle to simulate a sensor information and compare it with the observed sensor information (usually laser), so as to assign a probability to each particle. Then regenerate the particles according to the generated probability. 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.

7.2, Topics and Services

Subscribe to TopicsTypeDescription
scansensor_msgs/LaserScanLiDAR data
tftf/tfMessageCoordinate transformation information
initialposegeometry_msgs/PoseWithCovarianceStampedMean and covariance used to (re)initialize particle filters.
mapnav_msgs/OccupancyGridAfter setting the use_map_topic parameter, AMCL subscribes to this topic to retrieve maps for laser-based positioning. New in navigation 1.4.2.
Publish topicTypeDescription
amcl_posegeometry_msgs/PoseWithCovarianceStatmpedPose estimate of the robot in the map, with covariance information
particlecloudgeometry_msgs/PoseArrayPose estimate collection maintained by the particle filter
tftf/tfMessagePublish the conversion from odom to map
ServerTypeDescription
global_localizationstd_stvs/EmptyInitialize global localization, all particles are randomly scattered in the free area of ​​the map
request_normotion_updatestd_stvs/EmptyManually perform updates and publish updated particles
set_mapnav_msgs/SetMapService for manually setting a new map and pose.
ClientTypeDescription
static_mapnav_msgs/GetMapamcl calls this service to retrieve a map for laser positioning; start blocks getting maps from this service.

View Node

amclrosgraph

7.3, Parameter Configuration

There are three categories of ROS parameters that can be used to configure amcl nodes: overall filter, laser model, and odometry model.

ParameterTypeDefaultDescription
~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.99Upper standard normal quantile of (1-p), where p is the probability that the error of the estimated distribution is less than kld_err
~update_min_ddouble0.2(m)Translational distance required to perform one filter update
~update_min_adoublepi/6.0(rad)Rotational movement required to perform one filter update
~reseample_intervalint2Number of filter updates before resampling
~transform_tolerancedouble0.1(s)Time to publish the transform, indicating that this transform is valid in the future
~recovery_alpha_slowdouble0.0Exponential decay rate of the slow average weight filter, used to decide when to recover by adding random poses, 0.0 means disabled
~recovery_alpha_fastdouble0.0Exponential decay rate of the fast average weight filter, used to decide when to recover by adding random poses, 0.0 means disabled
~initial_pose_xdouble0.0(m)Initial pose average value (x), used to initialize the Gaussian distribution filter
~initial_pose_ydouble0.0(m)Initial pose average value (y), used to initialize the Gaussian distribution filter
~initial_pose_adouble0.0(m)Initial pose average value (yaw), used to initialize the Gaussian distribution filter
~initial_cov_xxdouble0.5*0.5(m)Average initial pose (x*x), used to initialize Gaussian distribution filter
~initial_cov_yydouble0.5*0.5(m)Average initial pose (y*y), used to initialize Gaussian distribution filter
~initial_cov_aadouble(pi/12)*(pi/12)(rad)Average initial pose (yaw*yaw), used to initialize Gaussian distribution filter
~gui_publish_ratedouble-1.0(Hz)Maximum rate of publishing information during visualization, -1.0 means disabled
~save_pose_ratedouble0.5(Hz)Maximum rate of storing pose estimates initial_pose_ and covariance initial_cov_ in the parameter server, used for subsequent filter initialization. -1.0 means disabled
~use_map_topicboolfalseWhen set to true, amcl will subscribe to the map topic instead of receiving the map via a service call
~first_map_onlyboolfalseWhen set to true, amcl will only use the first map it subscribes to instead of updating the received map every time
~selective_resamplingboolfalseWhen set to true, will reduce the resampling rate when not needed and help avoid particle starvation. Resampling will only occur when the number of effective particles (N_eff=1/(sum(k_i^2)) is less than half of the current number of particles.
ParameterTypeDefaultDescription
~laser_min_rangedouble-1.0Minimum scan range, set to -1, the minimum use range reported by the laser radar.
~laser_max_rangedouble-1.0Maximum scan range, set to -1, the maximum use range reported by the laser radar.
~laser_max_beamsint30How many evenly spaced beams to use in each scan when updating the filter
~laser_z_bitdouble0.95Blending weight for the z_bit portion of the model
~laser_z_shortdouble0.1Blending weight for the z_short portion of the model
~laser_z_maxdouble0.05Blending weight for the z_max portion of the model
~laser_z_randdouble0.05Blending weight for the z_rand portion of the model
~laser_sigma_hitdouble0.2(m)Standard deviation of the Gaussian model used in the z_hit portion of the model
~laser_lambda_shortdouble0.1Exponential decay parameter for the z_short portion of the model
~laser_likelihood_max_distdouble2.0(m)Maximum distance on the map at which to measure obstacle inflation
~laser_model_typestring"likelihood_field"Model choice, bean, likelihood_field, or likelihood_field_prob
ParameterTypeDefaultDescription
~odom_model_typestring"diff"Model choice, diff, omni, diff-corrected, or omni-corrected
~odom_alpha1double0.2Specifies the expected noise in the odometry rotation estimate, based on the rotation component of the robot's motion
~odom_alpha2double0.2Specifies the expected noise in the odometry rotation estimate, based on the translation component of the robot's motion
~odom_alpha3double0.2Specifies the expected noise in the odometry translation estimate, based on the translation component of the robot's motion
~odom_alpha4double0.2Specifies the expected noise in the odometry translation estimate based on the rotational component of the robot motion
~odom_alpha5double0.2Translation-related noise parameter (used only in model omni)
~odom_frame_idstring"odom"The coordinate frame of the odometry
~base_frame_idstring"base_link"The coordinate frame of the robot chassis
~global_frame_idstring"map"The coordinate frame published by the positioning system
~tf_broadcastbooltrueWhen set to false, amcl will not publish the coordinate transformation between map and odom

7.4 Coordinate transformation

amcl_localization.png

Comparison of two methods Odometry Localization and AMCL Map Localization:

Odometry Localization: The rotation speed of the wheel can be obtained through the feedback of the motor encoder, the current wheel speed can be obtained 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 total mileage can be obtained by integrating according to time.

AMCL Map Localization: In amcl, the position information of the base_frame corresponding to the map_frame has been obtained through particle filtering positioning, but in order to ensure that the base_frame has only one parent node, this conversion is not directly published, because the parent node of the base_frame is already odom_frame, then amcl can only publish the conversion from map_frame to odom_frame, which also has the advantage that we can get the cumulative error of odom.

We have been saying that the distance information obtained by the wheel odometer will have cumulative errors, which is similar to the car skidding. If the moving distance is calculated only by the wheel odometer, it will be wrong:

1.gif

For example: the robot moves forward in a straight line, and the result obtained by the wheel odometer should be 1 meter, so the distance from odom_frame should be 1 meter, but because of the slipping in place, the robot actually finds that it has not moved at all through amcl positioning, so amcl needs to publish the conversion from map_frame to odom_frame to remove the 1 meter error, so as to maintain the normality of the entire tf tree.

The conversion relationship between coordinates.

image-20240627151233392

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