PID Control

In this project, a demonstration of a PID controller is presented for steering control of a vehicle on a simulated track. This demonstration is based on a simulator developed by Udacity and was completed as part of Udacity's Self-Driving Car Nanodegree. The Udacity github repo for this project has all the details about the software used in the simulator and the installation instructions.

Summary of Setup Instructions

  1. The project uses uWebSocketIO for communication between the user-written algorithm and the simulator. Udacity has provided bash scripts to install this in both Linux/Mac environments. These scripts are included in this repo.
  2. The simulator can be downloaded from here.

Basic Build Instructions (Linux/Mac)

  1. Clone this repo.
  2. Make a build directory: mkdir build && cd build
  3. Compile: cmake .. && make
  4. Run it: ./pid This should setup a listener for the code to get data from the simulator.
  5. Launch the simulator from a terminal: ./
  6. Select the PID Control project and click start to start the simulation.

These steps should get any user in a Linux/Mac environment up and running with the code.

Steering Control of Car with PID

In this project, the plant (car) dynamics is modeled by the simulator. We are presenting the control interface for controlling the car around a simulated track. The control interface gets the cross-track error and speed from the simulator as inputs. The output of the control interface is the normalized steering wheel angle and throttle inputs to the simulator. Both steering wheel angle and throttle are normalized between [-1,1] respectively. Positive (Negative) values of the steering wheel input correspond to making left (right) turns while positive (negative) values of throttle correspond to acceleration (deceleration).

PID Concept

PID (stands for Proportional Integral and Derivative control) is a feedback control mechanism where the state/output feedback of the current state is compared to a set point and new control inputs are computed to drive the error between the current state/output and the set point to zero as shown in the image (from wikipedia) below.

image.png

In this model,

  1. the P term stands for a gain that is proportional to the current error.
  2. the I term stands for an integral of the errors accumulated over time. This error seeks to eliminate steady state errors.
  3. The D term stands for a derivative effect seeking to anticipate the rate of change of error.

Tuning this controller involves finding the gains $K_p$, $K_i$ & $K_d$ that results in an acceptable dynamic response of the plant to a given set point. In this project, the goal is to identify the gains for the steering controller such that the car always drives within the track limits of the simulator.