PID

PID (proportional-integral-derivative) is a technique used in line following (and many other systems with dynamic equilibrium) which allows robots to move in a much more natural seeming way rather than continually correcting itself and so usually oscillation along the line. One can interpret each part of a PID controller as indicators of errors depending on time, and therefore provide a system for correcting the robot.

Contents

Proportional

The proportional part, P, depends upon the present error and so indicates the current offset. If we consider a robot that is attempting to follow a line. It has a line sensing bar that allows it to detect when it is off the line. The robot can adjust the power to each motor to modify its direction and drive. A simple proportion control loop would simply cause the robot to turn back towards the line if it detected it had strayed from it, preferably with the amount it turns proportional to the distance it has strayed. The problem with this is that the robot will continually overshoot the line and stuff appear to oscillate along it.

Integral

The integral part, I, indicates the accumulated past error and so is used to detect when on curves. A more advanced system would have the robot continually increase the amount it turns if it is taking too long to reach the line. This is very helpful if on a curve. This can be approximated by continually summing and multiplying the error in position by the incremented time. However, if the lines direction is changing from say a curve to a straight line then the robot will simply continue turning after the curve stops and therefore overshoot the line significantly.

Derivative

The derivative part, D, helps predict the future error and so detect changes in direction. To achieve a more gradual conversion to the line the robot may wish to reduce the turning if the line is straightening up. This is the derivative component. This can be obtained by taking the difference between the instantaneous and previous error and dividing by the time increment.

PID

The weighted sum of these, if done correctly, can result in very natural and accurate movement. The easiest way to identify the coefficients of each term, to tune the control loop, is through trial and error, lots of trial and error. There are however, theoretical methods and various limitations to PID which are discussed on the wikipedia page.