11.AMCL

11.1 Introduction

The full English name of amcl is 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 positioning method, which uses an adaptive KLD method to update particles and uses particle filters to track the robot's pose based on a known map. As currently implemented, this node is only available for laser scans and laser maps. It can be extended to process other sensor data. amcl receives laser-based maps, laser scans, and transformation information, and outputs pose estimates. On startup, amcl initializes its particle filter according to 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

Adaptive Monte Carlo

11.2 Navigation and positioning test

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, to X3 for example.

Open the [.bashrc] file

Find the [ROBOT_TYPE] parameter and modify the corresponding model

11.2.1 Start

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

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

Open 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, its role is to tell the robot where.

After opening it, we can see that a handful of green particles are evenly scattered around the robot. When we randomly move the robot(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 a laser), thereby assigning a probability to each particle. Then, the particles are regenerated according to the generated probability, and 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 is calculated.

11.2 Topics and Services

Subscribe to topicstypedescribe
scansensor_msgs/LaserScanLidar data
tftf/tfMessageCoordinate transformation information
initialposegeometry_msgs/PoseWithCovarianceStampedMean and covariance used to(re)initialize the particle filter.
mapnav_msgs/OccupancyGridWhen the use_map_topic parameter is set, AMCL subscribes to this topic to retrieve maps for laser-based positioning. New in Navigation 1.4.2.
Post a topictypedescribe
amcl_posegeometry_msgs/PoseWithCovarianceStatmpedPose estimation of the robot in the map, with covariance information
particlecloudgeometry_msgs/PoseArrayA collection of pose estimates maintained by particle filters
tftf/tfMessagePost the conversion from odom to map
Servertypedescribe
global_localizationstd_stvs/EmptyInitialize global positioning, all particles are randomly scattered on the free area on the map
request_normotion_updatestd_stvs/EmptyPerform the update manually and publish the updated particles
set_mapnav_msgs/SetMapA service to manually set up new maps and poses.
clienttypedescribe
static_mapnav_msgs/GetMapamcl calls this service to retrieve maps for laser positioning; start prevents maps from being fetched 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: global filters, laser models, and odometer models.

parametertypeDefaultsdescribe
~min_particlesint100Minimum number of particles allowed
~max_particlesint5000maximum number of particles allowed
~kld_errdouble0.1Maximum error between true distribution and 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_adoubleft/6.0(rad)Rotational movement required to perform a filter update
~reseample_intervalint2number of filter updates before resampling
~transform_tolerancedouble0.1(s)When to publish the transform to indicate 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 resume operations by adding random poses, 0.0 disables
~recovery_alpha_fastdouble0.0Exponential decay rate of the fast average weight filter used to decide when to resume operations by adding random poses, 0.0 disables
~initial_pose_xdouble0.0(m)Initial pose mean(x), used to initialize the Gaussian filter
~initial_pose_ydouble0.0(m)Initial pose mean(y), used to initialize the Gaussian filter
~initial_pose_adouble0.0(m)Initial pose mean(yaw), used to initialize the Gaussian filter
~ initial_cov_xxdouble0.5*0.5(m)Initial pose mean(x*x), used to initialize the Gaussian distribution filter
~ initial_cov_yydouble0.5*0.5(m)Initial pose mean(y*y), used to initialize the Gaussian filter
~ initial_cov_aadouble(ft/12)*(ft/12)(rad)Initial pose mean(yaw*yaw), used to initialize the Gaussian distribution filter
~gui_publish_ratedouble-1.0(Hz)When visualizing, the maximum rate at which information is published, -1.0 means disable
~save_pose_ratedouble0.5(Hz)the parameter server and covariance initial_cov for subsequent initialization filters. -1.0 means disable
~use_map_topicboolfalseWhen set to true, amcl will subscribe to the map topic instead of receiving maps via service calls
~first_map_onlyboolfalseWhen set to true, amcl will only use the first map it subscribes to, not the map it receives with each update
~selective_resamplingboolfalseWhen set to true, will reduce the resampling rate when not needed and help avoid particle deprivation. Resampling occurs only when the effective number of particles(N_eff=1/(sum(k_i^2)) is less than half of the current number of particles.
parametertypeDefaultsdescribe
~laser_min_rangedouble-1.0Minimum scan range, set -1, the minimum usage range reported by the lidar.
~laser_max_rangedouble-1.0Maximum scan range, set -1, the maximum usage range reported by the lidar.
~laser_max_beamsint30How many evenly spaced beams to use in each scan when updating the filter
~ laser_z_bitdouble0.95Mixed weights for the z_bit part of the model
~laser_z_shortdouble0.1Mixed weights for the z_short part of the model
~laser_z_maxdouble0.05Mixed weights for the z_max part of the model
~laser_z_randdouble0.05Mixed weights for the z_rand part of the model
~laser_sigma_hitdouble0.2(m)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)Measure the maximum distance on the map that the obstacle swells
~laser_model_typestring"likelihood_field"Model selection, bean, likelihood_field or likelihood_field_prob
parametertypeDefaultsdescribe
~odom_model_typestring"diff"Model selection, diff, omni, diff-corrected or omni-corrected
~odom_alpha1double0.2Specifies the expected noise in the odometry rotation estimate based on the rotational component of the robot's motion
~odom_alpha2double0.2Specifies the expected noise in the odometry rotation estimate based on the translational component of the robot's motion
~odom_alpha3double0.2Specifies the expected noise in the odometry translation estimate based on the translational 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's motion
~odom_alpha5double0.2Translation-dependent noise parameter(only used in model omni)
~odom_frame_idstring"odom"The coordinate system of the odometer
~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 speed of the wheel can be known through the encoder feedback of the motor, the current speed of the wheel 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 movement can be obtained by integrating according to time. total mileage.

AMCL Map Localization: In amcl, the pose information of the base_frame corresponding to the map_frame has been obtained through particle filter positioning, but in order to ensure that the base_frame has only one parent node, the conversion will not be published directly, because the parent node of the base_frame is already odom_frame, then amcl can only publish the conversion of 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 measurement information obtained by the wheel odometer will have a cumulative error, which is similar to the car slipping. If only the wheel odometer is used to calculate the moving distance, there will be an error:

1.gif

For example: the robot walks straight ahead, and the result obtained by the wheel odometer should be 1 meter, then the distance from odom_frame should be 1 meter, but due to the slipping in place, in fact, the robot does not move at all through amcl positioning, then amcl needs to publish the conversion of map_frame to odom_frame to remove this 1-meter error, so as to maintain the normality of the entire tf tree.

The transformation relationship between coordinates.

image-20220224171032366

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