Kalman Filters for Object Tracking

November 15, 2017

This post will be less invovled than some of the other projects but you can look at the code for the extended kalman filter and unscented kalman filter if you want more details! Also, if you want to read more about kalman filters and understand how these types of models work feel free to read this intuitive and well written blog.

In this project, we use an extended kalman filter and later an unscented kalman filter to predict the location and velocity of a simulated bicycle that is traveling around the vehicle. The measurement data comes from lidar and radar sensors with the main algorithm implemented in C++.

Extended Kalman Filter

In the screenshots below, the green triangles represent the predicted location, the red circles are from the laser sensor, and the blue markers are from the radar sensor. We measure the accuracy of the algorithm by calculating the RMSE of the x, y positions and the velocity along the x, y axis.

alt text

  • The original dataset starting with lidar measurement

alt text

  • Reverse of the original dataset starting with radar measurement

If we just use one or the other of the sensor measurements to update the algorithm we can start to see what each sensor is better.

alt text

  • The original dataset starting with lidar measurement and only using the lidar measurements to update to algorithm. We can see that compared to using both sources of sensor data the overall algorithm performs worse.

alt text

  • The original dataset starting with lidar measurement and only using the radar measurements to update to algorithm. Compared to using only the lidar data, the radar only updated algorithm is worse at localizing the positon (higher RMSE for x and y).

Unscented Kalman Filter

alt text

  • The original dataset starting with lidar measurement

Overall, the unscented kalman filter performs better than the extended kalman filter. The RMSE values are lower in general, but especially the velocity predictions are much better for the unscented kalman filter. One reason for this might be that mechanically, the unscented kalman filter doesn't employ a linear process model nor does it linearize the non-linear measurement model. Rather, it uses an unscented transform to approximate the non-linear transformation. With regards to the process model (or motion model), instead of a constant velocity model we switched to using a constant turn rate and velocity magnitude model, which is better able to model how objects behave in turns.

alt text

  • Using only the lidar measurements, the overall algorithm performs worse especially with regard to the velocity predictions.

alt text

  • Similar to the extended kalman filter case, using just the radar measurements, the algorithm performs worse then with just the lidar or both sensors.

One difference in terms of the two filters is the use of the normalized innovation squared (NIS) metric to finetune the noise parameters that are used in the unscented kalman filter. The NIS metric gives an approximate idea of whether or not the parameters were initialized in the correct range. Specifically, the NIS follows a Chi-squared distribution and given the number of dimensions we can figure out what the value should be if we expect that only in 5% of the cases the NIS will exceed the value. In our case, for the radar measurement example we have 3 dimensions and the value that we expect to exceed 5% of the time is 7.815. For the lidar, since there are 2 dimensions (the x and y position) the value we expect to exceed ~5% of the time is 5.991.

alt text

  • For the lidar NIS, we see that only in about ~5% of the cases does the value of the NIS exceed the 5.991 value.

alt text

  • Similarly, for the radar NIS, about ~5% of the time the NIS exceeds 7.815

Compile and Build

In order to compile and build this project, make sure that the following dependencies are met.

  • cmake:
  • For Mac make sure that cmake is at least version 3.5
  • make:
  • For Mac make sure that make is at least version 4.1
  • gcc/g++:
  • For Mac make sure that gcc/g++ is at least version 5.4
  • uWebSocketIO
  • From the project directory run install-mac.sh, which should be linked to the necessary cmakepatch.txt file
  • In order to run the above shell script, homebrew should also be installed

Once the above dependencies are installed:

  1. Clone this repository
  2. Create a build directory and navigate into it
  3. mkdir build && cd build
  4. Compile
  5. cmake .. && make
  6. Run the program
  7. Make sure that the Udacity simulator is installed
  8. ./ExtendedKF or
  9. ./UnscentedKF

© Jeff Wen. Built using Pelican. Theme by Giulio Fidente on github. ¦ Archives