What is AMCL? Localization on an existing map with a particle filter
Atlasbot · 17/8/2026 · 11 min read
The EKF track tracks uncertainty with a Gaussian ellipsoid — pseudo-real location that always lies around a single vertex. AMCL (Adaptive Monte Carlo Localization) — Nav2's standard localization algorithm — solves the same localization problem but with a completely different approach: particle filter, which does not pre-assume the shape of the location distribution.
Key concepts
Instead of a single ellipsoid, AMCL maintains a large set of particles (particles) — each particle is an independent hypothesis about the robot's (x, y, θ) position. The loop consists of 3 steps, repeated continuously:
1. PREDICT — moves each particle according to the received odometry data
(similar to EKF's Predict step, but applied to each individual particle)
2. UPDATE — matches the predicted LiDAR scan at each particle location with the actual measured LiDAR scan
→ The closer the predicted particle is to reality, the higher the weight
3. RESAMPLE — gradually remove low weight particles, duplicate high weight particles
around the most likely correct region
In short: EKF answers "what is the average position, how much deviation" by the closure formula. AMCL answers the same question by trying thousands of possibilities at the same time and then selecting gradually — more computationally expensive, but not constrained by the Gaussian distribution assumption, handling well even cases where the initial position is completely unknown (multi-modal).
How it works
AMCL does not keep the number of particles constant throughout the process — using the KLD-sampling technique: more particles when uncertainty is high, gradually decreasing the number of particles when converged. This is why AMCL consumes computational resources that vary over time and are not constant.
Required input:
- Static map is available (from SLAM — package map_server)
- Continuous odometry data (Predict step)
- Continuous LiDAR data (Update step)
Output:
- Transform map → odom — is the absolute "anchor" that compensates for the drift error of odometry
Unlike SLAM (both map building and localization), AMCL assumes the map is fixed — the standard process of an AMR robot is to run SLAM once to build the map, save it, then switch to running AMCL for the next operating sessions.
Technical details
Formulas
The weights of each particle must be normalized to sum to 1 before resample — ensuring particles with higher weights are replicated in the correct relative proportions:
w_i_chuan_hoa = w_i / Σ(w_j) for all j
Example: 3 particles with rough weights 0.8, 0.5, 0.2 (based on LiDAR scan fit)
Total = 1.5
w1 = 0.8/1.5 ≈ 0.53, w2 = 0.5/1.5 ≈ 0.33, w3 = 0.2/1.5 ≈ 0.13
→ seed 1 has ~53% chance of being duplicated in the resample step, seed 3 only ~13%
Parameters
The number of configuration particles in Nav2 (min_particles/max_particles) directly affects the balance between accuracy and computational load:
| Parameter | Typical value |
|---|---|
min_particles | ~100 – 500 (when well converged) |
max_particles | ~2000 – 5000 (at startup, location unknown) |
Practical applications
Particle filter solves the classic problem "kidnapped robot problem" — the situation where the robot is suddenly moved to another location without any recorded odometry data (eg: picked up and put back in another place, or has a serious wheel slip that completely loses track). AMCL can recover by periodically "injecting" a few more random particles distributed throughout the map (random particle injection) — if the old estimated location no longer matches the new LiDAR data, new random particles have a chance to "capture" the ground truth and gradually dominate through subsequent resample rounds. This is exactly what EKF cannot do due to the assumption of a single Gaussian peak (stated in the previous article) — an important reason why AMCL is still the standard choice for global localization despite being more computationally expensive than EKF.
Practical example
import random
# Simple 1D simulation: true position = 5.0
vi_tri_that = 5.0
particles = [random.uniform(0, 10) for _ in range(5)] # randomly distribute 5 particles
def trong_so(p, target, sigma=1.0):
return pow(2.718, -((p - target)**2) / (2 * sigma**2))
weights = [trong_so(p, vi_tri_that) for p in particles]
tong = sum(weights)
weights_chuan_hoa = [w/tong for w in weights]
for p, w in zip(particles, weights_chuan_hoa):
print(f"Hat tai {p:.2f}: trong so chuan hoa = {w:.3f}")
Output (vi du, ngau nhien moi lan chay khac nhau):
Hat tai 4.82: trong so chuan hoa = 0.312
Hat tai 1.15: trong so chuan hoa = 0.002
Hat tai 5.34: trong so chuan hoa = 0.287
Hat tai 8.90: trong so chuan hoa = 0.001
Hat tai 5.71: trong so chuan hoa = 0.398
Particles close to the ground truth (5.0) receive a much higher weight than far particles — in the next resample step, particles with high weights (4.82, 5.34, 5.71) will be duplicated many times, particles with weights near 0 (1.15, 8.90) almost disappear — the particle population gradually "clusters" around the ground truth as described in the Main Concepts section.
Common mistakes
- Too few particles cause "particle deprivation" — not enough hypothetical diversity to properly represent the multi-modal situation, which is especially dangerous right after the robot is "abducted" — needs enough
max_particlesto have a chance of recovery. - Too many particles cause computational overload on embedded hardware — running AMCL with
max_particlestoo high on a weak Raspberry Pi/Jetson can cause the localization update frequency to drop below the safe threshold for the upper control loop. - Static map assumption is no longer true — AMCL does not handle well when the actual environment changes significantly compared to the saved map (store shelves are moved, newly built areas) — need to rerun SLAM to update the map when the environment changes significantly, cannot just rely on AMCL to adapt itself.
- Give AMCL an initial pose estimate that is too far off from the ground truth — if the initial pose set on RViz2 is too far from the ground truth, most of the initial particles are concentrated in the wrong area, converge slowly, or fail completely — always set the initial pose as close to reality as possible when initializing AMCL.
Conclusion
AMCL solves the global localization problem with a particle filter — thousands of competing hypotheses through a predict-update-resample loop, not constrained by the single-peak Gaussian assumption like EKF, at the expense of higher computational cost. This is the last article of the Localization section, and also closes the entire section Robotics Fundamentals — from Mathematics for Robotics (vector, matrix, quaternion), Robot kinematics (forward/inverse kinematics, differential drive, mecanum), Robot Control (PID, closed-loop, trajectory), to Localization (odometry, IMU, sensor fusion, EKF, AMCL) just learned — enough background The core mathematical and algorithmic foundation for understanding and customizing any real robot navigation system, even complex packages like Nav2.
Get new articles and lessons by email
When a new technical article or course module is published, Atlas Robotics sends you a short email. No spam.
Unsubscribe any time with the link in each email. See our Privacy policy.