Path Planning — (Behavior)
The behavior module takes as inputs the map, the route and the prediction of what other vehicles do. The output is the suggested maneuver.
The output of this module is a suggestion of maneuvers/states that are feasible, safe, legal and efficient.

One approach to solve the behavioral problem is the use of Finite State Machine, which makes decisions based on a finite set of discrete states.
It takes some inputs and uses a state transition function to decide which state to go next.
For a self-driving car there are many states we can consider (i.e. slow down, pass a vehicle, accelerate, stop, change lane right, etc).
However, for simplicity we focus on 5 states:
- Lane Keep — identified in Frenet coordinates by:
- d — stay near the center line.
- s — drive at target speed when feasible.
- Lane Change Left/Right — identified with:
- d — move to the left/right.
- s — same rule as before.
- Prepare Lane Change Left/Right — identified with:
- d — stay near the center line for the current lane.
- s — attempt to match the position and the speed of the “gap” in the lane we attempt to move.
- activate turning signal.
The inputs to the transition function are:
- Predictions
- Map
- Speed limit
- Localization data
- Current state
One way to implement a transition function is by generating rough trajectories for each accessible “next state” and then finding the best.
To “find the best” trajectory we use a cost function. We want to figure out how “costly” each rough trajectory is and select the lowest cost trajectory. Therefore, we penalize the wrong “actions” and reward the right ones.
The cost function takes into consideration several parameters (i.e. speed, acceleration, position, etc), each balanced by a weight.
These weights reflect the type of problem the cost function is trying to address.
For example: feasibility, safety, legality, comfort, and efficiency.
This article has been inspired by the Udacity Self-Driving Car Nanodegree lectures (https//www.udacity.com)

