/sdc-unscented-kalman-filter

An unscented Kalman filter implementation using the CTRV motion mode to estimate the state of a moving object based on noisy lidar and radar measurements.

Primary LanguageC++

Unscented Kalman Filter Project

This project utilizes an Unscented Kalman Filter to estimate the state of a moving object of interest with noisy lidar and radar measurementsand obtaining RMSE values that are lower that the tolerance outlined in the project rubric.

Results

Comparisson of the different sensors as well as the fused result

In order to validate the Unscented Kalman Filter performance, the filter was applied in three scenarios. While using: both the radar and lidar sensors, only the lidar sensor and only the radar sensor. After comparing the three respective oucomes we validate that the fusion of both the radar and lidar sensors provided the best result.

alt text

Simulation with both Radar and Lidar - On: youtube video

alt text

Simulation with only the Lidar - On: youtube video

alt text

Simulation with only the Radar - On: youtube video

The table below summarizes the results for the three runs. It is clear that sensor fusion provided the best results for all the RMSE values (X, Y, VX, VY):

Sensor X Y VX VY
Both 0.0890 0.0947 0.3949 0.2078
Lidar 0.1090 0.1109 0.4554 0.2679
Radar 0.2285 0.2227 0.4423 0.3913

NIS - Normalized Innovation Squared

The program calculates the NIS as can be seen in the following sample run: alt text

The NIS distribution follows the table below with df = 3 for the radar and df = 2 for the lidar.

df x^2.950 x^2.900 x^2.100 x^2.050
2 0.103 0.211 4.605 5.991
3 0.352 0.584 6.251 7.815

From the sample run we can see that we are slightly underestimating the lidar performance since only 3.212% percent of the measurements exceed the 5% line. However, the radar NIS is 4.819% which is very close to 5%.

Comparisson with the Extended Kalman Filter results

The results that we obtained using the unscented kalman filter are sligthly better than the results that we got using the extended kalman filter on the same set of data.

Installation

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 install 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.

Important Dependencies

Basic Build Instructions

  1. Clone this repo
  2. Make a build directory: mkdir build && cd build
  3. Compile: cmake .. && make
  • On windows, you may need to run: cmake .. -G "Unix Makefiles" && make
  1. Run it: ./UnscentedKF
$ mkdir build && cd build
$ cmake .. && make
$ ./UnscentedKF

Note: If you want to run the program with different sensor configuration see the ./src/constants.h file.

Data flow between the program and the Simulator

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

["sensor_measurement"] => the measurement that the simulator observed (either lidar or radar)

OUTPUT: values provided by the c++ program to the simulator

["estimate_x"] <= kalman filter estimated position x ["estimate_y"] <= kalman filter estimated position y ["rmse_x"] ["rmse_y"] ["rmse_vx"] ["rmse_vy"]

Generating Additional Data

If you'd like to generate your own radar and lidar data, see the utilities repo for Matlab scripts that can generate additional data.