This repository is a compact SLAM study project for a differential-drive robot. It implements and compares two classical approaches to Simultaneous Localization and Mapping (SLAM):
- EKF-SLAM: a single Gaussian estimate for robot pose and landmarks.
- FastSLAM: a particle-based estimate for robot pose with per-landmark Gaussian filters.
The project is designed as a small simulation application: you can run a scenario, watch the robot move, see landmarks being estimated in real time, and inspect the final metrics and plots.
The accompanying report, Report.pdf, explains the theoretical background, implementation choices, and experimental conclusions.
The repository simulates a robot moving in a 2D world with point landmarks. During the simulation:
- The robot follows a commanded trajectory.
- Wheel encoder noise corrupts odometry.
- A range-bearing sensor observes nearby landmarks.
- A SLAM algorithm estimates:
- the robot trajectory,
- the landmark map,
- and uncertainty over time.
The main goal is to compare how EKF-SLAM and FastSLAM behave under noisy sensing, imperfect motion, nonlinear motion patterns, and uncertain data association.
Based on Report.pdf:
- EKF-SLAM works well in simpler settings and can build accurate maps when data association remains reliable.
- FastSLAM 2.0 is generally more robust in nonlinear and noisy scenarios.
- The most fragile part of the SLAM pipeline is data association.
- Loop closure is especially important for EKF-SLAM.
- Both approaches can degrade in hard scenarios with high noise and ambiguous landmark observations.
The Simulation package contains the synthetic environment and sensor models shared by both algorithms.
- Simulation/World.py: creates 2D landmark maps, either random or circular.
- Simulation/Robot.py: simulates a differential-drive robot, ground-truth motion, and noisy wheel-encoder odometry.
- Simulation/Sensor.py: simulates range-bearing landmark measurements with noise, dropout, spurious readings, and glitches.
- Simulation/Visualization.py: plotting utilities for EKF-SLAM.
The EKF_SLAM package implements a classical Extended Kalman Filter SLAM pipeline.
- EKF_SLAM/EKF_SLAM.py: core EKF-SLAM class.
- state prediction from odometry,
- measurement model and Jacobians,
- nearest-neighbor style data association,
- candidate landmark management,
- landmark insertion into the state vector,
- batch Joseph-form style covariance update.
- EKF_SLAM/main.py: runnable experiment script for EKF-SLAM.
- builds the world,
- runs the simulation loop,
- computes metrics such as RMSE and OSPA,
- shows online and final plots.
The FastSLAM package contains two particle-based variants.
- FastSLAM/FastSLAM_1.py: FastSLAM-style implementation using proposal distributions and per-particle landmarks.
- FastSLAM/FastSLAM_2.py: a more advanced FastSLAM 2.0 style implementation where measurements influence proposal updates.
- FastSLAM/Particle_1.py: particle and landmark logic for the first variant.
- FastSLAM/Particle_2.py: particle and landmark logic for the second variant.
- FastSLAM/Visualization.py: visualization utilities for particles, paths, observations, and landmarks.
- FastSLAM/main_1.py: main comparison-ready FastSLAM experiment with metrics and plots.
- FastSLAM/main_2.py: a simpler FastSLAM 2.0 demo script.
No matter which algorithm you run, the flow is roughly the same:
- Generate a world with landmarks.
- Initialize the robot and sensor.
- Initialize the chosen SLAM estimator.
- Repeatedly:
- move the robot,
- generate noisy observations,
- predict the new state,
- associate observations with landmarks,
- update the map and robot estimate,
- visualize progress.
- Print final statistics and show summary plots.
The project evaluates performance with:
- Trajectory RMSE: average pose error along the path.
- OSPA: a metric that evaluates both localization quality and landmark set mismatch.
- Landmark matching statistics: number found, missed, and false positives.
- Uncertainty traces: estimator confidence over time.
These are implemented directly in the runnable scripts, mainly in EKF_SLAM/main.py and FastSLAM/main_1.py.
The code imports only a small scientific Python stack:
numpyscipymatplotlib
A recent Python 3 version should be sufficient.
From the repository root, run one of the following:
python EKF_SLAM/main.pypython FastSLAM/main_1.pypython FastSLAM/main_2.py
Each script opens Matplotlib windows for online visualization and prints final performance statistics in the terminal.
If you are new to the repository, this is the easiest reading order:
- Report.pdf for motivation and conclusions.
- Simulation/World.py, Simulation/Robot.py, and Simulation/Sensor.py to understand the simulated environment.
- EKF_SLAM/main.py or FastSLAM/main_1.py to see the full experiment loop.
- Then open the algorithm core:
Best when you want:
- a compact single-state estimator,
- explicit covariance tracking,
- a more classical probabilistic robotics baseline.
Trade-offs:
- sensitive to wrong data association,
- depends on linearization,
- scales less gracefully as the map grows.
Best when you want:
- stronger robustness in nonlinear settings,
- multiple pose hypotheses through particles,
- better behavior under harder observation conditions.
Trade-offs:
- more computationally expensive,
- more parameters to tune,
- map quality still depends heavily on reliable association.
- The repository is focused on simulation, not real robot deployment.
- Landmark observations are anonymous: the algorithms must manage association uncertainty.
- Visualization is an important part of the project; most scripts are meant to be run interactively.
- The code is research/project oriented rather than packaged as a library.
Good next improvements would be:
- stronger data association, such as JCBB,
- configuration files for experiment presets,
- command-line arguments for choosing scenario and noise levels,
- saving plots automatically,
- reproducible benchmark datasets.
In short, this repository is a teaching/research project that compares EKF-SLAM and FastSLAM 2.0 in a controlled 2D simulation. If you want to understand the project quickly, start with Report.pdf, then run EKF_SLAM/main.py and FastSLAM/main_1.py to see both estimators in action.