yubrshen / CarND-PID-Control-Project

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

CarND-Controls-PID

Self-Driving Car Engineer Nanodegree Program


Achievement

A PID controller is implemented. A message-driven twiddle procedure for PID parameters is implemented. I also did a prototype of message-driven twiddle process in Python first for proof of concept. It may serve as a reference for implementation in C++.

The PID controller with manually selected parameters such as {0.2, 3.0, 0.004} for P, D, I respectively with constant throttle 0.4 can achieve stable driving the full track with top speed of 45 mph.

With adaptive throttle rule of $0.7 - \sqrt{fabs(angle)\cdot speed\cdot fabs(cte)}$, through twiddle process a set of paramters were found that can enable mostly safe driving with top speed of 70 mph, and most of the time the speed is above 40 mph. There are two incidents where that the car drove over to the lanes markings usually forbidden.

Painstaking effort were made to search for parameters for safer driving. But I was only able to minimize the number of incidents of traffic violations.

In the future, I might try to use another PID to control the throttle.

I did attempted on the effort, so far with my current found formula for ideal speed: $MAX_SPEED \cot (1 - \frac {\sqrt{angle}} {5})$ where $ 5 = \sqrt{25}$ and 25 is considered to be the maximum angle, I feel the error signal being the difference between the idea speed given steering angle and the current speed may not capture the requirement that the speed at the extreme angle 25 should be very small regardless to the current speed. But I had not found good expression for the ideal speed thus I have not further attempted.

Here is a capture of the running at high speed after twiddle process:

The following shows the typical twiddle process.

The follow shows only P component in the controller:

It will only work when there is not much change in the speed of cte change.

The follow shows only the D component in the controller:

It performs even worse, as it does not account for the presence of cte directly, only will account of the change of cte.

This shows only the I component in the controller:

It performs the worst, as it only response to the accumulation of cte.

Dependencies

Basic Build Instructions

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

About


Languages

Language:C++ 98.0%Language:Python 1.8%Language:CMake 0.2%Language:Shell 0.1%