Path-Planning

This project designs a Path Planner composed of a Vehicle, a Highway, a Behavior Planner and a Trajectory Planner to make smooth, comfortable, safe paths for a autonomous vehicle drives along a highway. It communicates with Udacity simulator to receive localization, sensor fusion data and transmit trajectory of the vehicle.The diagram below can be seen for overall system architecture:

System Architecture

Trajectory Planner

Spline fitting method has used to calculate upcoming path of the vehicle. Two prior waypoints have been added to a list with 3 upcoming waypoints which are from 30m, 60m and 90m ahead of the vehicle. Finally this list points with their y equivalent coordinates taken from highway map are fitted to spline. By so calculated spline function is used to lead the vehicle for upcoming waypoints. The Trajectory Planner achieves this fitting a spline [http://kluge.in-chemnitz.de/opensource/spline/] to the waypoints by using previous path of the vehicle and upcoming path of the vehicle until 30m ahead of it.

Behavior Planner

This subsystem is responsible of given a decision for states like cruising, lane change or tailing by setting target lane and target velocity parameters. Via calculation of time to collision and costs for each lane the behavior planner decides which state the vehicle should be in. Time to collision is calculated according to distance in between egovehicle and nearest vehicle in that lane. Higher time to collision stands longer duration to an accident. Cost function is sum of lane flow speed and distance in between egovehicle and nearest vehicle in that lane. Slower lane and near tailing of upcoming vehicle leads to high cost for that lane and behavior planner decides target lane up to lowest cost and ensures to avoid an accident with high time to collision value.

--

Project instructions given by Udacity are as follows:

Simulator.

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).

Goals

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.

The map of the highway is in data/highway_map.txt

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.

Basic Build Instructions

  1. Clone this repo.
  2. Make a build directory: mkdir build && cd build
  3. Compile: cmake .. && make
  4. Run it: ./path_planning.

Here is the data provided from the Simulator to the C++ Program

Main car's localization Data (No Noise)

["x"] The car's x position in map coordinates

["y"] The car's y position in map coordinates

["s"] The car's s position in frenet coordinates

["d"] The car's d position in frenet coordinates

["yaw"] The car's yaw angle in the map

["speed"] The car's speed in MPH

Previous path data given to the Planner

//Note: Return the previous list but with processed points removed, can be a nice tool to show how far along the path has processed since last time.

["previous_path_x"] The previous list of x points previously given to the simulator

["previous_path_y"] The previous list of y points previously given to the simulator

Previous path's end s and d values

["end_path_s"] The previous list's last point's frenet s value

["end_path_d"] The previous list's last point's frenet d value

Sensor Fusion Data, a list of all other car's attributes on the same side of the road. (No Noise)

["sensor_fusion"] A 2d vector of cars and then that car's [car's unique ID, car's x position in map coordinates, car's y position in map coordinates, car's x velocity in m/s, car's y velocity in m/s, car's s position in frenet coordinates, car's d position in frenet coordinates.


Dependencies