Skip to content
Switch branches/tags

Latest commit


Git stats


Failed to load latest commit information.
Latest commit message
Commit time


This is an implementation of a 2 dimensional particle filter in C++. The particle filter is given a map and some initial localization information (analogous to what a GPS would provide). At each time step the filter also gets observation and control data.

Running the Code

Once you have this repository on your machine, cd into the repository's root directory and run the following commands from the command line:

> ./
> ./
> ./

NOTE If you get any command not found problems, you will have to install the associated dependencies (for example, cmake)

If everything worked you should see something like the following output:

Time step: 2444
Cumulative mean weighted error: x .1 y .1 yaw .02
Runtime (sec): 38.187226
Success! Your particle filter passed!

######Otherwise you might get...

Time step: 100
Cumulative mean weighted error: x 39.8926 y 9.60949 yaw 0.198841
Your x error, 39.8926 is larger than the maximum allowable error, 1

Implementing the Particle Filter

The directory structure of this repository is as follows:

|   CMakeLists.txt
|   |   control_data.txt
|   |   gt_data.txt
|   |   map_data.txt
|   |
|   |___observation
|       |   observations_000001.txt
|       |   ...
|       |   observations_002444.txt
    |   helper_functions.h
    |   main.cpp
    |   map.h
    |   particle_filter.cpp
    |   particle_filter.h

Inputs to the Particle Filter

You can find the inputs to the particle filter in the data directory.

The Map*

map_data.txt includes the position of landmarks (in meters) on an arbitrary Cartesian coordinate system. Each row has three columns

  1. x position
  2. y position
  3. landmark id

Control Data

control_data.txt contains rows of control data. Each row corresponds to the control data for the corresponding time step. The two columns represent

  1. vehicle speed (in meters per second)
  2. vehicle yaw rate (in radians per second)

Observation Data

The observation directory includes around 2000 files. Each file is numbered according to the timestep in which that observation takes place.

These files contain observation data for all "observable" landmarks. Here observable means the landmark is sufficiently close to the vehicle. Each row in these files corresponds to a single landmark. The two columns represent:

  1. x distance to the landmark in meters (right is positive) RELATIVE TO THE VEHICLE.
  2. y distance to the landmark in meters (forward is positive) RELATIVE TO THE VEHICLE.

NOTE The vehicle's coordinate system is NOT the map coordinate system.


A proof of concept Particle Filter Library written in C++




No releases published


No packages published