Self-Driving Car Engineer Nanodegree Program
In this project a Kalman Filter estimates the state of a moving object of interest with noisy lidar and radar measurements with the RMSE values lower than the required tolerance.
- cmake >= 3.5
- All OSes: click here for installation instructions
- make >= 4.1
- Linux: make is installed by default on most Linux distros
- Mac: install Xcode command line tools to get make
- Windows: Click here for installation instructions
- gcc/g++ >= 5.4
- Linux: gcc / g++ is installed by default on most Linux distros
- Mac: same deal as make - [install Xcode command line tools]((https://developer.apple.com/xcode/features/)
- Windows: recommend using MinGW
- 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:
./ExtendedKF
- Download the simulator and open it. In the main menu screen select Project 1: Bicycle tracker with EKF.
- Once the scene is loaded you can hit the START button to observe how the object moves and how measurement markers are positioned in the data set. Also for more experimentation, "Data set 2" is included which is a reversed version of "Data set 1", also the second data set starts with a radar measurement where the first data set starts with a lidar measurement. At any time you can press the PAUSE button, to pause the scene or hit the RESTART button to reset the scene. Also the ARROW KEYS can be used to move the camera around, and the top left ZOOM IN/OUT buttons can be used to focus the camera. Pressing the ESCAPE KEY returns to the simulator main menu.
- The EKF project Github repository README has more detailed instructions for installing and using c++ uWebScoketIO.
NOTE: Currently hitting Restart or switching between Data sets only refreshes the simulator state and not the Kalman Filter's saved results. The current procedure for refreshing the Kalman Filter is to close the connection, ctrl+c
and reopen it, ./ExtendedKF
. If you don't do this when trying to run a different Data set or running the same Data set multiple times in a row, the RMSE values will become large because of the the previous different filter results still being observed in memory.
##Editor Settings
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.
This is optional!
If you'd like to generate your own radar and lidar data, see the utilities repo for Matlab scripts that can generate additional data.
Note: regardless of the changes you make, your project must be buildable using cmake and make!
More information is only accessible by people who are already enrolled in Term 2 of CarND. If you are enrolled, see the project resources page for instructions and the project rubric.
- You don't have to follow this directory structure, but if you do, your work will span all of the .cpp files here. Keep an eye out for TODOs.
Help your fellow students!
We decided to create Makefiles with cmake to keep this project as platform agnostic as possible. Similarly, we omitted IDE profiles in order to we ensure that students don't feel pressured to use one IDE or another.
However! We'd love to help people get up and running with their IDEs of choice. If you've created a profile for an IDE that you think other students would appreciate, we'd love to have you add the requisite profile files and instructions to ide_profiles/. For example if you wanted to add a VS Code profile, you'd add:
- /ide_profiles/vscode/.vscode
- /ide_profiles/vscode/README.md
The README should explain what the profile does, how to take advantage of it, and how to install it.
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. Please see this concept in the classroom for the required version and installation scripts.
Once the install for uWebSocketIO is complete, the main program can be built and run by doing the following from the project top directory.
- mkdir build
- cd build
- cmake ..
- make
- ./ExtendedKF
Note that the programs that need to be written to accomplish the project are src/FusionEKF.cpp, src/FusionEKF.h, kalman_filter.cpp, kalman_filter.h, tools.cpp, and tools.h
The program main.cpp has already been filled out, but feel free to modify it.
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"]
The github repo contains one data file:
data/obj_pose-laser-radar-synthetic-input.txt
Here is a screenshot of the first data file:
The simulator will be using this data file, and feed main.cpp values from it one line at a time.
Screenshot of Data File
Each row represents a sensor measurement where the first column tells you if the measurement comes from radar (R) or lidar (L).
For a row containing radar data, the columns are: sensor_type, rho_measured, phi_measured, rhodot_measured, timestamp, x_groundtruth, y_groundtruth, vx_groundtruth, vy_groundtruth, yaw_groundtruth, yawrate_groundtruth.
For a row containing lidar data, the columns are: sensor_type, x_measured, y_measured, timestamp, x_groundtruth, y_groundtruth, vx_groundtruth, vy_groundtruth, yaw_groundtruth, yawrate_groundtruth.
Whereas radar has three measurements (rho, phi, rhodot), lidar has two measurements (x, y).
You will use the measurement values and timestamp in your Kalman filter algorithm. Groundtruth, which represents the actual path the bicycle took, is for calculating root mean squared error.
Yaw and yaw rate will be introduced in the UKF lecture (you will use the same data set for the UKF project). You do not need to worry about yaw and yaw rate ground truth values.
We have provided code that will read in and parse the data files for you. This code is in the main.cpp
file. The main.cpp
file creates instances of a MeasurementPackage.
If you look inside 'main.cpp', you will see code like:
MeasurementPackage meas_package;
meas_package.sensor_type_ = MeasurementPackage::LASER;
meas_package.raw_measurements_ = VectorXd(2);
meas_package.raw_measurements_ << px, py;
meas_package.timestamp_ = timestamp;
and
vector<VectorXd> ground_truth;
VectorXd gt_values(4);
gt_values(0) = x_gt;
gt_values(1) = y_gt;
gt_values(2) = vx_gt;
gt_values(3) = vy_gt;
ground_truth.push_back(gt_values);
The code reads in the data file line by line. The measurement data for each line gets pushed onto a measurement_pack_list
. The ground truth [px,py,vx,vy] for each line in the data file gets pushed ontoground_truth
so RMSE can be calculated later from tools.cpp
.
To review what we learned in the extended Kalman filter lectures, let's discuss the three main steps for programming a Kalman filter:
- initializing Kalman filter variables
- predicting where our object is going to be after a time step Δt
- updating where our object is based on sensor measurements
Then the prediction and update steps repeat themselves in a loop.
To measure how well our Kalman filter performs, we will then calculate root mean squared error comparing the Kalman filter results with the provided ground truth.
These three steps (initialize, predict, update) plus calculating RMSE encapsulate the entire extended Kalman filter project.
The files you need to work with are in the src
folder of the github repository.
main.cpp
- communicates with the Term 2 Simulator receiving data measurements, calls a function to run the Kalman filter, calls a function to calculate RMSEFusionEKF.cpp
- initializes the filter, calls the predict function, calls the update functionkalman_filter.cpp
- defines the predict function, the update function for lidar, and the update function for radartools.cpp
- function to calculate RMSE and the Jacobian matrix
The only files you need to modify are FusionEKF.cpp
, kalman_filter.cpp
, and tools.cpp
.
Here is a brief overview of what happens when you run the code files:
Main.cpp
reads in the data and sends a sensor measurement toFusionEKF.cpp
FusionEKF.cpp
takes the sensor data and initializes variables and updates variables. The Kalman filter equations are not in this file.FusionEKF.cpp
has a variable calledekf_
, which is an instance of aKalmanFilter
class. Theekf_
will hold the matrix and vector values. You will also use theekf_
instance to call the predict and update equations.- The
KalmanFilter
class is defined inkalman_filter.cpp
andkalman_filter.h
. You will only need to modify 'kalman_filter.cpp', which contains functions for the prediction and update steps.
Regardless of the IDE used, every submitted project must still be compilable with cmake and make.