Giter Club home page Giter Club logo

carnd-pid-control-project's Introduction

Self-Driving Car Engineer Nanodegree

Luis Miguel Zapata


PID Control

This projects aims to develop PID controller to position a simulated autonomous car as close as posible to the middle of a lane.

1. Environment.

Simulator is based in Unity and mimics a car for autonomous driving in a single lane road. The vehicle is controlled from a c++ script using web sockets and its velocity will increment constantly untill it reaches 100mph. The task of our controller is to maintain the vehicle within the road commanding the appropiate steering angles using a given cross track error or in other words how far is the car from the lanes center.

1. PID controller.

As stated before the PID controller uses the cross track error to calculate steering angle commands, however, it is not only the current CTE (cross track error) that account for aor equations, but we also need its derivative and its integral. In discrete terms a derivative is just the current measurement minus the previous measurement, taht is why we store previous mesurements at every iteration. On the other hand the integral is not more than the summatory of all CTEs.

p_error = cte;
i_error += cte;
d_error = cte - prev_cte;
prev_cte = cte;

Having defined the proportional, detivative and integral gains (Kp, Kd, Ki) the PID equation will simply be as follows:

return -Kp * p_error - Kd * d_error - Ki * i_error; 

1. PID tuning.

The proportional term in the PID controller is the one that tries to directly compensate for the error observed, however, this direct compensation is not always proportionl to the chosen parameter and in many ocassions compansates more than what is necessary causing overshoots.

The derivative term compensantes for changes in the CTE over time, for instance if the error is constant the derivative does no correction. However in this case the derivative term compensates for the overshoot caused by the proportional term.

Finally the integral term compensates for the stationary state error or bias.

There are many methodologies to chose appropiate PID gains such as twiddle tought in this same course. The methodoly used this time was by trial an error using the following steps:

  • Set all gains to zero.
  • Increase the P gain until the response to a disturbance is steady oscillation.
  • Increase the D gain until the the oscillations go away.
  • Repeat steps 2 and 3 until increasing the D gain does not stop the oscillations.
  • Set P and D to the last stable values.
  • Increase the I gain until it brings you to the setpoint with the number of oscillations desired (normally zero but a quicker response can be had if you don't mind a couple oscillations of overshoot)

The chosen values where:

double Kp = 0.25;
double Ki = 0.001;
double Kd = 3.0;

carnd-pid-control-project's People

Contributors

lmzh123 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.