GrandMasterJedi / PID-VehicleController

Implementation of Proportional Integral Derivative to Control Steering Angle of a Vehicle

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Demo of PID (Proportional Integral Derivative) Controller for Vehicle Steering

Within a simulated environment a vehicle drives autonomously a virtual circuit. The vehicle tries to stay in the center of the circuit lane as the PID controller, implemented in c++, controls the steering angle of the vehicle.

This project is my solution to term 2, assignment 4 of the Udacity Self-Driving Car Engineer Nanodegree Program

Data Flow

  • The simulator takes data from the PID and provides cross-trach error (CTE), previous throttle and yaw.
  • The PID submit a new steering angle and adjust throttle value (speed) to the simulator

Output

The vehicle run in the simulated circuit. The examples below show the vehicle running in a straight circuit segment, whith a speed exceeding 30mph and the vehicle behavior in a tight curvature.
alt text alt text


Dependencies

There's an experimental patch for windows in this PR

Basic Build Instructions

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

Reflection

Describe the effect each of the P, I, D components had in your implementation.

In this implementation the PID controller is used to directly control only the steering angle. The speed (throttle) is calibrated based the steering angle. The P, I, and D components have each a function to control steering angle based on the "cross tracking error" (CTE).

  • The P (proportional) component control the short run steering variation. If this value is high, the vehicle tends to oscillate around the trajectory, causing an unconformable ride. On the other side, if this value is too low, the vehicle is not able to turn enough around corners, causing the vehicle to go off track.
  • The D (derivative or differential) component is a steering counterweight. If this value is too high then vehicle tend to turn too slowly causing issues around corners, while, if this value is too low, then there is no adjustment to the steering rate so the vehicle may oscillate too much.
  • With the I (integral) component we keep track of all previous CTEs, thus it is a long range steering component. When this component is too high, the vehicle has too much memory and tend to change direction abruptly.

Describe how the final hyperparameters were chosen

I choose the final hyperparameters manually by experimenting in the simulation. For example, when I observed the vehicle oscillate too much then I first decrease P or increase D. The parameter value for the integral component I is set close to 0.

I experiment different value for throttle as well. Fix and low value for throttle worked fine the resulting speed was too low. In my implementation I made the throttle value dependent on steering value, such that when the steering value is high, the throttle value is low. On the contrary, when there is no steering, the throttle value increases.


References

About

Implementation of Proportional Integral Derivative to Control Steering Angle of a Vehicle

License:Other


Languages

Language:C++ 99.5%Language:Shell 0.3%Language:CMake 0.1%