Giter Club home page Giter Club logo

carnd-p9-pid_controller's Introduction

CarND-Controls-PID

Self-Driving Car Engineer Nanodegree Program


Overview

This project implements a PID controller to keep a car on a race track by properly adjusting the steering angle.

What is a PID controller?

A controller is used to manage the steering, throttle and brakes to move a vehicle where we'd like it to go. A Proportional–Integral–Derivative (PID) controller is one of the most common forms of these control loop feedback mechanisms. A PID controller continuously calculates an error function (in this case: the distance from the center of the lane) and applies a correction based on proportional (P), integral (I), and derivative (D) terms.

Choosing PID Parameters

The behavior of a PID controller depends on three main parameters, or control gains:

  1. Proportional - involves steering the vehicle proportionally to cross track error, which is the lateral difference between the vehicle and its reference trajectory. This process results in slightly, continuously overshooting the desired path:

    steering = -tau * cte

    Tau is the control parameter and increasing this figure makes the vehicle converge with the reference trajectory faster (oscillation is faster with a higher tau).

  2. Integral - magnitude of error, as well as the duration of error are taken into account. In this way the controller is able to eliminate the residual steady-state error that occurs with a pure proportional controller (i.e. a purely proportional controller operates only when error is non-zero) and is able to deal with systematic biases. The integral is utilized to eliminate steering drift.

  3. Derivative (or Differential) - the goal is to avoid the overshoot that occurs when using a P controller. The steering alpha is also related to the temporal derivative of the cross track error. This means that when the car has turned enough to reduce the cross track error, it will recognize this and counter steer as the error becomes smaller over time.

In this project, parameters were manually tuned by qualitatively inspecting the driving behavior in the simulator, in response to parameter changes. I used the classroom examples as a starting point for trial and error. Test run videos are included in the submission for P controller and PID controller (doesn't seem to be any bias so showing a PD controller example as well seems pointless). Results from various parameters are noted in the code.

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.

Editor Settings

We've purposefully kept editor configuration files out of this repo in order to keep it as simple and environment agnostic as possible. However, we recommend using the following settings:

  • indent using spaces
  • set tab width to 2 spaces (keeps the matrices in source code aligned)

Code Style

Please (do your best to) stick to Google's C++ style guide.

Project Instructions and Rubric

Note: regardless of the changes you make, your project must be buildable using cmake and make!

More information is only accessible by people who are already enrolled in Term 2 of CarND. If you are enrolled, see the project page for instructions and the project rubric.

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.