Skip to content

gdangelo/CarND-Path-Planning-Project

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CarND-Path-Planning-Project

Path Planning Project for Self-Driving Car ND

Udacity - Self-Driving Car NanoDegree

Path Planning

The goal of this project is to design a path planner that is able to create smooth, safe paths for the car to follow along a 3 lanes highway with traffic. A successful path planner will be able to keep inside its lane, avoid hitting other cars, and pass slower moving traffic all by using localization, sensor fusion, and map data.

In other words, the car :

  • Should be able to drive at least 4.32 miles without incident. Incidents include exceeding acceleration/jerk/speed, collision, and driving outside of the lanes.
  • Should be able to drive according to the speed limit (50 mph). The car shouldn't drive faster than the speed limit. Also the car shouldn't drive much slower than speed limit unless obstructed by traffic.
  • Does not exceed max Acceleration (10 m/s^2) and Jerk (10 m/s^3).
  • Must not come into contact with any of the other cars on the road.
  • Stays in its lane, except for the time between changing lanes. The car doesn't spend more than a 3 seconds length outside the lanes during changing lanes, and every other time the car stays inside one of the 3 lanes on the right hand side of the road.
  • Should be able to smoothly change lanes when it makes sense to do so, such as when behind a slower moving car and an adjacent lane is clear of other traffic.

Overview

Starting to work on this project consists of the following steps:

  1. Clone this repository
  2. Build & compile the main program
    • mkdir build && cd build
    • cmake .. && make
  3. Launch ./path_planning
  4. Launch the Udacity Term 3 simulator
  5. Enjoy!

Installation and Dependencies

This project involves the Udacity Term 3 Simulator which can be downloaded here.

Other Important Dependencies

Once all the dependencies have been installed clone the project:

git clone https://github.com/gdangelo/CarND-Path-Planning-Project/

and follow the steps 2 to 5 of the Overview section in order to build and run the main program.


Implementation

My implementation is composed of two main parts which are the prediction and behavior planning, and the trajectory generation. See details below.

1. Prediction/Behavior

The prediction and behavior planning has been implemented under the SimpleBehaviorPlanner function starting from line 323. Based on the current state of the ego car and data from sensor fusion, the system decides what the car should do. By interpreting and understanding the surrounding environment, it finds the best possible behavior to adopt in order to drive safely and efficiently:

  • We first look at cars in front of us blocking the traffic (see lines 332 to 366). If it is the case, the car must consider to change lane (see lines 368 to 371).
  • Otherwise, the car stays in the same lane and keep going by speeding up until we reach the speed limit (see lines 372 to 375).

Lane changing is handle by a distinct function named TryChangingLane starting from line 296. This function is checking lanes for safety based on distance from cars and current speed see line 199 to 222. If no other lane is safe to drive, the ego car stays on its lane and slow down to reach the front car speed.

2. Trajectory

Thanks to the previous step, we know how the car should behave. Whether it's has to change lane or drive straight, its path must be as smooth as possible. This is done under the GenerateTrajectory function starting from line 378.

Trajectory calculation is initiated using the spline library. To ease computation the map coordinates are transformed to local car coordinates (see lines 420 to 425). Points are then sampled from spline result and added to previous remaining path points in order to ensure more continuity to the trajectory.


Possible Improvements

  • Implement emergency braking
  • Enhance trajectory generation by:
    1. Sampling a large number of end configurations near the desired position where we want the car to drive
    2. Generate corresponding trajectories and discard all non-drivable ones
    3. Pick the best trajectory based on jerk-minimizing cost function

Questions or Feedback

Contact me anytime for anything about my projects or machine learning in general. I'd be happy to help you 😉