In this project you will implement a 2 dimensional particle filter in C++. Your particle filter will be given a map and some initial localization information (analogous to what a GPS would provide). At each time step your filter will also get observation and control data.
If you have already installed all the necessary dependencies for the projects in term 2 you should be good to go! If not, you should install them to get started on this project => Getting Started for Term 2.
- Clone this repo.
- Make a build directory:
mkdir build && cd build
- Compile:
cmake .. && make
- On Windows, you may need to run:
cmake .. -G "Unix Makefiles" && make
- On Windows, you may need to run:
- Run it:
./particle_filter
Once you launched the executable, simply run the simulator app and select the "Project 3: Kinapped Vehicle" simulation.
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
Your robot 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. Does your particle filter localize the vehicle within the desired accuracy? Does your particle run within the specified time of 100 seconds? Does your code use a particle filter to localize the robot?
The new Term 2 Simulator includes a graphical version of the Project 3 Kidnapped Vehicle Project. Running the simulator you can see the path that the car drives along with all of its landmark measurments. The simulator provides the noisy position data, vehicle controls, and noisy observations. The script feeds back the best particle state.
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
The only file you should modify is particle_filter.cpp
in the src
directory. The file contains the scaffolding of a ParticleFilter
class and some associated methods. Read through the code, the comments, and the header file particle_filter.h
to get a sense for what this code is expected to do.
If you are interested, take a look at src/main.cpp
as well. This file contains the code that will actually be running your particle filter and calling the associated methods.
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.
The general idea of the solution is as follows:
- Initialize particles with initial position, orientation and noise
- Update particle position based on current particles, their orientation and noise
- For each particle, determine landmarks within sensor range
- Map particle observations to map coordinates
- Compute particle weight using vectors to the observation and landmark (distance and angle error)
- Resample particle weights
- Repeat 2 - 6 for each observation
Using 100 particles is reliable in estimating the positions within the tolerances desired for the project. But there is a wide range of numbers of particle you can choose for meeting the projects desired tolerances. Starting with 8000 particles gives the best values for the localisation but it's most time-consuming. Going down to 5 particles, this is much faster but just within the localistion tolerances. So the optimal choice is a set with 100 particles with beeing only 3 secondes slower as the 5 particles set and less then 7% worse in the estimation of the position as the 8000 particles set.
The simulator displays the best particle's sensed positions, along with the corresponding map ID associations. This can be extremely helpful when making sure transition and association calculations were done correctly. Below is a video of what it looks like when the simulator successfully is able to track the car to a particle. Notice that 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.
The job is to build out the methods in particle_filter.cpp
until the simulator output says:
Success! Your particle filter passed!
The resulting videos are in the repo, if you are interested.
We've purposefully kept editor configuration files out of this repo in order to keep it as simple and environment agnostic as possible. However, we recommend using the following settings:
- indent using spaces
- set tab width to 2 spaces (keeps the matrices in source code aligned)
Please (do your best to) stick to Google's C++ style guide.
No further updates nor contributions are requested. This project is static.
Term2_project8_particle_filter_kidnapped_vehicle results are released under the MIT License