🧭 SLAM: Simultaneous Localization and Mapping
A robot explores a hidden maze it has never seen. A real Monte Carlo particle filter localizes it from noisy lidar-like range readings and noisy odometry, while a Bayesian log-odds occupancy grid builds the map live — genuinely computed each step, not pre-drawn.
Drag to orbit · Scroll to zoom · WASD/Arrows to drive manually when Manual control is on
How to read this simulation
Green arrow — the true robot (hidden from the algorithm, shown for teaching purposes). Orange marks — particle filter hypotheses; brighter means higher weight. Grey/white cells — the occupancy grid the robot has built from its own noisy sensor data: dark cells are believed free, bright cells are believed occupied, and mid-grey cells are still unknown. Toggle "Show true maze" to compare the built map against the hidden ground truth.
The Particle-Filter SLAM Loop
Predict — every particle's
pose is advanced using the same noisy odometry reading the real
robot reports, plus extra per-particle motion noise, so the cloud
spreads to represent uncertainty.
Weight — each particle
casts simulated sensor rays against the occupancy grid built so
far from its own hypothesis pose, and is weighted by how closely
those predicted ranges match the real robot's actual noisy lidar
readings.
Resample — particles are
redrawn proportional to weight (systematic resampling), so
likely poses multiply and unlikely ones vanish, concentrating
the cloud around the true pose over time.
Map — the weighted-mean
pose estimate (not the hidden ground truth) is used to trace
every sensor ray through the occupancy grid, accumulating
Bayesian log-odds evidence for free and occupied cells — this is
why the map only sharpens once localization has converged.