PID controller
One of the limitations of the proportional controller is that a value for the gain in your program might be ideal for only one type of curve. For instance, the parameters that work well for tracking a straight line might not work as well on sharp curves. In some instances, the correction might not be strong enough, and in others, your robot might overcorrect. The PID controller attempts to compensate for these environmental variations.
We have already discussed the ideas behind the proportional controller. The strength of the correction is proportional to the error of how far our sensor reading is from the setpoint. If we are consistently having to include a large and consistent correction (say we are always a bit too far off the edge of the line), then we must have needed a stronger gain. The way to account for this on the fly is to have the robot remember that it has been consistently off the line (or too far above/below the setpoint) for a period of time and increase the...