Udacity Self-Driving Car Nanodegree - Kidnapped Vehicle project
This project implements a Particle Filter applied to a Kidnapped robot(car) problem. A simulator is provided by Udacity (it could be downloaded here). This simulator will generate noisy landmark observation from a car to the Particle Filter using WebSocket. The Particle Filter uses the uWebSockets WebSocket implementation to respond to this observation with the estimated car position. Udacity provides a seed project to start from on this project (here).
The project has the following dependencies (from Udacity’s seed project):
- cmake >= 3.5
- make >= 4.1
- gcc/g++ >= 5.4
- Udacity’s simulator.
For instructions on how to install these components on different operating systems, please, visit Udacity’s seed project. As this particular implementation was done on Mac OS, the rest of this documentation will be focused on Mac OS. I am sorry to be that restrictive.
In order to install the necessary libraries, use the install-mac.sh.
Compiling and executing the project
In this project, Udacity’s seed repo provides scripts to clean, compile and run it. These are the following commands you need to run from this repo directory
> ./clean.sh > ./build.sh > ./run.sh
You will see a message indicating the filter is listening:
> ./run.sh Listening to port 4567
When you open the simulator the following screen appears:
Using the right arrow, you need to go to the Kidnapped Vehicle project:
Clicking on “Select,” the simulator for the Kidnapped project start and the Particle Filter informs it is connected:
Clicking on “Start” button, the vehicle starts moving, and the blue circle(the filter calculated position) moves with it. After a while, the simulator informs you if your Particle Filter passed or failed. Here is an example of the filter passing the test:
The Particle Filter is implemented in src/particle_filter.cpp:
Initialization: Particle initialization is implemented at ParticleFilter::init from line 24 to line 62.
Prediction: The prediction step is implemented at ParticleFilter::prediction from line 64 to line 100.
Weight’s update: This is the more important operation in my opinion. It is implemented at ParticleFilter::updateWeights from line 138 to line 217.
Almost the rest of the magic happens on src/main.cpp. The event handler declared at line 49 parse the received message and call the above described Particle Filter methods.