Self-Driving Car Engineer Nanodegree Program
You can download the Term3 Simulator which contains the Path Planning Project from the [releases tab (https://github.com/udacity/self-driving-car-sim/releases/tag/T3_v1.2).
In this project your goal is to safely navigate around a virtual highway with other traffic that is driving +-10 MPH of the 50 MPH speed limit. You will be provided the car's localization and sensor fusion data, there is also a sparse map list of waypoints around the highway. The car should try to go as close as possible to the 50 MPH speed limit, which means passing slower traffic when possible, note that other cars will try to change lanes too. The car should avoid hitting other cars at all cost as well as driving inside of the marked road lanes at all times, unless going from one lane to another. The car should be able to make one complete loop around the 6946m highway. Since the car is trying to go 50 MPH, it should take a little over 5 minutes to complete 1 loop. Also the car should not experience total acceleration over 10 m/s^2 and jerk that is greater than 10 m/s^3.
Each waypoint in the list contains [x,y,s,dx,dy] values. x and y are the waypoint's map coordinate position, the s value is the distance along the road to get to that waypoint in meters, the dx and dy values define the unit normal vector pointing outward of the highway loop.
The highway's waypoints loop around so the frenet s value, distance along the road, goes from 0 to 6945.554.
- Clone this repo.
- Make a build directory:
mkdir build && cd build
- Compile:
cmake .. && make
- Run it:
./path_planning
.
Here is the data provided from the Simulator to the C++ Program
- 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
- uWebSockets
- Run either
install-mac.sh
orinstall-ubuntu.sh
. - If you install from source, checkout to commit
e94b6e1
, i.e.git clone https://github.com/uWebSockets/uWebSockets cd uWebSockets git checkout e94b6e1
- Run either
I downloaded spline.h
according to the QA session and put it to src
folder. The compilation went through.
The car is able to drive without any incidents for at least 4.32 miles. I made a video
on YouTube. Below are the screenshots while the ego vehicle was driving.
The criteria include the following:
- The car drives according to the speed limit.
- No speed limit reg flag was seen.
- Max Acceleration and Jerk are not Exceeded.
- No max jerk red flag was seen.
- Car does not have collisions.
- No collision red flag was seen.
- The car stays in its lane, except for the time between changing lanes.
- Most of time the car stays in its lane unless there is a car ahead of it, or need to merge onto the center lane.
- The car is able to change lanes
- The car is able to change lane when there is a slower car ahead of it and no traffic around, or needs to change back to center lane if and only if there is no traffic around.
The starter code is leveraged from the QA session. The algorithm starts from line 245 of main.cpp
.
From line 245-289 I implemented the code to determine whether there is a car ahead of the ego car, left to the car or right to the car. The condition is met if the distance measured from the sensors is within 30m from the ego car.
Line 291-314 decides whether the car needs to change lane. There are two conditions below and if either one is met the car changes lane.
- There is a slower car ahead and there is no left/right car within 30m.
- The car is on the left/right lane and wants to change back to the center lane, and there is no cars on the direction it wants to merge on. Line 310-313 is used when the car is about to start. This is to avoid the high jerk when the car starts to reach the max speed.
Line 321-420 calculate the trajectory points. The car orientation is calculated from the last two points of the previous path points. Then there are three points at farther distances are included for the spline calculation.