A vehicle has been kidnapped and transported to a new location ! Luckily it has a map of this location, a (noisy) GPS estimate of its initial location, and lots of (noisy) sensor and control data. In this project , 2 dimensional particle filter is implemented in C++ to localize the vehicle in the map. The particle filter will be given a map and some initial localization information (analogous to what a GPS would provide). At each time step the filter will also get observation and control data.
This project is done as part of the self-driving car nanodegree .
- 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
- uWebSocketIO
- This package facilitates the connection between the simulator and code by setting up a web socket server connection from the C++ program to the simulator, which acts as the host.
- To install it on linux , run the script
install-ubuntu.sh
. - To install it on mac , run the script
install-mac.sh
.
- This project involves the Term 2 Simulator which can be downloaded here
Once the install for uWebSocketIO is complete, the main program can be built and ran by doing the following from the project top directory.
- mkdir build
- cd build
- cmake ..
- make
- ./particle_filter
Alternatively some scripts have been included to streamline this process, these can be leveraged by executing the following in the top directory of the project:
- ./clean.sh
- ./build.sh
- ./run.sh
Here is the main protcol that main.cpp uses for uWebSocketIO in communicating with the simulator.
INPUT: values provided by the simulator to the c++ program
// sense noisy position data from the simulator
["sense_x"]
["sense_y"]
["sense_theta"]
// get the previous velocity and yaw rate to predict the particle's transitioned state
["previous_velocity"]
["previous_yawrate"]
// receive noisy observation data from the simulator, in a respective list of x/y values
["sense_observations_x"]
["sense_observations_y"]
OUTPUT: values provided by the c++ program to the simulator
// best particle values used for calculating the error evaluation
["best_particle_x"]
["best_particle_y"]
["best_particle_theta"]
//Optional message data used for debugging particle's sensing and associations
// for respective (x,y) sensed positions ID label
["best_particle_associations"]
// for respective (x,y) sensed positions
["best_particle_sense_x"] <= list of sensed x positions
["best_particle_sense_y"] <= list of sensed y positions
To complete the project , build out the methods in particle_filter.cpp
until the simulator output says:
Success! Your particle filter passed!
The directory structure of this repository is as follows:
root
| build.sh
| clean.sh
| CMakeLists.txt
| README.md
| run.sh
|
|___data
| |
| | map_data.txt
|
|
|___src
| helper_functions.h
| main.cpp
| map.h
| particle_filter.cpp
| particle_filter.h
src/particle_filter.h
contains the declaration ofParticleFilter
class.src/particle_filter.cpp
contains the implementation ofParticleFilter
class.src/main.cpp
contains the code that will actually be running your particle filter , calling the associated methods and communicationg with the simulator.
You can find the inputs to the particle filter in the data
directory.
map_data.txt
includes the position of landmarks (in meters) on an arbitrary Cartesian coordinate system. Each row has three columns
- x position
- y position
- landmark id
- Map data provided by 3D Mapping Solutions GmbH.
If the particle filter passes the current grading code in the simulator , the simulator output says:
Success! Your particle filter passed!
-
Accuracy: your particle filter should localize vehicle position and yaw to within the values specified in the parameters
max_translation_error
andmax_yaw_error
insrc/main.cpp
. -
Performance: your particle filter should complete execution within the time of 100 seconds.
The simulator is able to track the car to a particle as the green laser sensors from the car nearly overlap the blue laser sensors from the particle, this means that the particle transition calculations were done correctly.