This project implements a particle filter algorithm to localize a vehicle using map landmarks to achieve higher positional precision than raw GPS.
The algorithm follows the following steps:
-
Initialize the filter's particles by randomly sampling from a Gaussian distribution around the initial GPS position and orientation [x, y, theta].
-
After the vehicle moves for timestep dt with a known control velocity and yaw rate,* use CTRV motion equations to predict the position of the particles and add additional Gaussian uncertainty around these predicted particle positions and orientations.
-
For each particle position, pre-filter map landmarks that are within sensor range and match each of the vehicle's measured observations (RADAR/LIDAR range finding) to the nearest map landmark.
-
Set each particle's weight by the multivariate Gaussian probability of how the measured observation [x, y] position matches the associated map landmark [x, y] position for each of the measured observations, multiplying them all together to get the total particle weight value.
-
Resample the set of particles with the probability based on the particle weights to re-center them on the best matches from the landmark observations.
-
Visualize the best particle with the highest weight and it's associated observations as the filter's output vehicle position.
Error X: 0.116
Error Y: 0.108
| File | Description |
|---|---|
| /src/main.cpp | Source code for main loop that handles uWebSockets communication to simulator |
| /src/particle_filter.cpp, .h | Source code for particle filter algorithm that localizes vehicle position by sampling particles that best match measured map landmark observations |
| /build/particle_filter | Output executable program binary |
| install-mac.sh | Script for Mac to install uWebSocketIO required to interface with simulator |
| install-ubuntu.sh | Script for Linux to install uWebSocketIO required to interface with simulator |
The original Udacity project repository is here.
This project involves the Udacity Term 2 Simulator which can be downloaded here
This repository includes two scripts (install-mac.sh and install-ubuntu.sh) that can be used to set up and install uWebSocketIO for either Linux or Mac systems.
Once the install for uWebSocketIO is complete, the main program can be built and run by doing the following from the project top directory.
- mkdir build
- cd build
- cmake ..
- make
- ./particle_filter
- cmake >= 3.5
- All OSes: click here for installation instructions
- make >= 4.1 (Linux, Mac), 3.81 (Windows)
- Linux: make is installed by default on most Linux distros
- Mac: install Xcode command line tools to get make
- Windows: Click here for installation instructions
- gcc/g++ >= 5.4
- Linux: gcc / g++ is installed by default on most Linux distros
- Mac: same deal as make - install Xcode command line tools
- Windows: recommend using MinGW