Giter VIP home page Giter VIP logo

pid-controller's Introduction

Autonomous driving with PID controllers

1. Objective

This project is to use PID controllers to control the steering angle and the throttle for driving a car in a game simulator. The simulator provides cross-track error (CTE) via websocket. The PID (proportional-integral-differential) controllers give steering and throttle commands to drive the car reliably around the simulator track.

Demo 1: Steady drive with constant throttle (click to see the full video)

demo_gif1

2. Parameters of PID controller

Description of PID values in PID control

  • P (proportional) accounts for present values of the error. For example, if the error is large and positive, the control output will also be large and positive.

  • I (integral) accounts for all past values of the error. For example, if the current output is not sufficiently strong, the integral of the error will accumulate over time, and the controller will respond by applying a stronger action.

  • D (differential) accounts for possible future trends of the error, based on its current rate of change.

Finally parameters

  • PID parameters used for steering angles:

    • p value: 0.1
    • i value: 0.001
    • d value: 2.8
  • PID parameters used for throttle:

    • p value: 0.45
    • i value: 0.000
    • d value: 0.5

How to tune the parameters

The parameters are tuned manually with the order of: p, d, i. The d and i are first setted to be zeros, and 0.2 is used for the p value. I adjust the p value up and down till it could drive around the first corner and hard to imporve more. Then I keep the p value as it is, and increase the d value. Use the same approach for d value and i value.

In order to automatically fine tune the parameters, an optimization algorithm twiddle can be used, which is exampled as follows:

Demo 2: speedy drive, which is targeting for dirivng the car as fast as possible, but as a side effect, the car starts to swing. In order to make the car drive fast as well as steady, further joint parameter tuning for both PID controllers need to be carried out.


Code & Files

1. Dependencies & environment

  • cmake >= 3.5
  • make >= 4.1
  • gcc/g++ >= 5.4
  • uWebSockets: used for communication between the main code and the simulator.

2. How to run the code

  1. Clone this repo.
  2. Clean the project: $./clean.sh
  3. Build the project: $./build.sh
  4. Run the project: $./run.sh
  5. Start the simulator v1.45, select the PID Controller.

3. My project files

4. Code Style

5. Release History

  • 0.1.1

    • First proper release
    • Date 14 July 2017
  • 0.1.0

    • Create the repo
    • Date 13 July 2017

pid-controller's People

Contributors

junshengfu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

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