Skip to content

allaydesai/Sparse-Localization-Using-Particle-Filter

Repository files navigation

Sparse Localization Using Particle Filter

Udacity - Self-Driving Car NanoDegree

Self-Driving Car Engineer Nanodegree Program

Overview


PROJECT DESCRIPTION

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.

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.

Particle filter invovles using a known map location along with a set of landmarks. The goal is to estimate position based on noisy sensor data and nearby landmarks. Starting location is provided using GPS input. The accuracy of position estimate is improved by updating weights added to each particle. Finally, the particles are resampled based on their respective weights resulting in only probable particles surviving.

alt text

Project Goals

The goals / steps of this project are the following:

  • Build a particle filter for sparse localization

  • Accuracy: your particle filter should localize vehicle position and yaw to within the values specified in the parameters max_translation_error and max_yaw_error in src/main.cpp.

  • Performance: your particle filter should complete execution within the time of 100 seconds.

Project Files

The directory structure of this repository is as follows:

root
|   build.sh
|   clean.sh
|   CMakeLists.txt
|   README.md
|   run.sh
|
|___data
|   |   
|   |   map_data.txt
|   
|___images
|   |   particle_sim_result.PNG
|   |   particle_output.gif
|
|___src
    |   helper_functions.h
    |   main.cpp
    |   map.h
    |   particle_filter.cpp
    |   particle_filter.h

Project Simulator

This project involves Tracking Simulator which can be downloaded here

This project involves the Term 2 Simulator which can be downloaded here

This repository includes two files that can be used to set up and intall uWebSocketIO for either Linux or Mac systems. For windows you can use either Docker, VMware, or even Windows 10 Bash on Ubuntu to install uWebSocketIO. Please see this concept in the classroom for the required version and installation scripts.

Project Dependencies

  • cmake: 3.5
  • make: 4.1 (Linux and Mac), 3.81 (Windows)
  • gcc/g++: 5.4
  • uWebSocketIO: Use install-ubuntu.sh

Project Build Instructions

Once the install for uWebSocketIO is complete, the main program can be built and ran by doing the following from the project top directory.

  1. mkdir build
  2. cd build
  3. cmake ..
  4. make
  5. ./UnscentedKF

Other Important Dependencies

Implementing the Particle Filter

The implementation is broken into the following steps:

  1. Transform observations from vehicle to map coordinates
  2. Find closest landmarks using nearest neighbour algorithm
  3. Update weight of the particle using multivariate gaussian probability density function
  4. Resample set of particles based on their weights/probability

Interaction with simulator

Here is the main protocol 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

Your job is to build out the methods in particle_filter.cpp until the simulator output says:

Success! Your particle filter passed!

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

All other data the simulator provides, such as observations and controls.

  • Map data provided by 3D Mapping Solutions GmbH.

Important Equations

  1. Transformation from Vehicle coordinates to Map coordinates

alt text

alt text

alt text

  1. Multivariate Gaussian Probability Density

alt text

Result

The vehicle was succesfully localized.

alt text

About

Implement a 2 dimensional particle filter in C++

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages