Self-Driving Car Engineer Nanodegree Program
Based on the vehicle kinematic model, the state variables include the
Actuators include the steering angle and the acceleration (throttle).
The update equations for the model:
where
The time horizon (
The general guidelines say that
Once
All computations are performed in the vehicle coordinate system. The coordinates of waypoints in vehicle coordinates are obtained by first shifting the origin to the current poistion of the vehicle and a subsequet 2D rotation to align the x-axis with the heading direction. The waypoints are obtained in the frame of the vehicle. A third order polynomial is then fitted to the waypoints. The transformation between coordinate systems is implemented. The transformation used is
waypoints_xs[i] = dx * cos(-psi) - dy * sin(-psi);
waypoints_ys[i] = dy * cos(-psi) + dx * sin(-psi);
where waypoints_xs, waypoints_ys
denote coordinates in the vehicle coordinate system.
The 100 ms latency is considered in the kinematic model, as follows:
const double current_px = 0.0 + v * dt;
const double current_py = 0.0;
const double current_psi = 0.0 + v * (-delta) / Lf * dt;
const double current_v = v + a * dt;
const double current_cte = cte + v * sin(epsi) * dt;
const double current_epsi = epsi + v * (-delta) / Lf * dt;
Result 1: YouTube video
Result 2: YouTube video
Given a set of hyperparameters, the vehicle may drive safely for one loop. But the performance is not stable for different loops or new simulations. Therefore, the vehicle drives safely for one loop does not mean we have the optimal set of hyperparameters. Monta Carlo runs are needed and parameter tuning continued until a stable drive.
The parameter tuning takes time, one possible method is decreasing the speed.
- It's recommended to test the MPC on basic examples to see if your implementation behaves as desired. One possible example is the vehicle starting offset of a straight line (reference). If the MPC implementation is correct, after some number of timesteps (not too many) it should find and track the reference line.
- The
lake_track_waypoints.csv
file has the waypoints of the lake track. You could use this to fit polynomials and points and see of how well your model tracks curve. NOTE: This file might be not completely in sync with the simulator so your solution should NOT depend on it. - For visualization this C++ matplotlib wrapper could be helpful.)
- Tips for setting up your environment are available here
- VM Latency: Some students have reported differences in behavior using VM's ostensibly a result of latency. Please let us know if issues arise as a result of a VM environment.