The Math
This is the formula for calculating the powers/velocities we want to apply to the mechanism to make it move to the destinations we want (e.g. calculations for velocities we want to apply to the car to make it move 1 meter forward).
\(u(t) = K_p e(t) + K_i \int_{0}^{t} e(\tau) \, d\tau + K_d \frac{de(t)}{dt}\)
Parts of Each Formula:
- \(u(t)\) is the control input. This can be velocity, steering angle, etc.
- \(e(t)\) is the error. For example, if you are controlling based on velocity, the error would be the difference between a desired velocity and the actual current velocity.
- \(K_p\) is the proportional gain, \(K_i\) is the integral gain, and \(K_d\) is the derivative gain.
Components:
Proportional Control (P)
This component produces an output value that's proportional to the current error. If the error has been large for an extended period of time, it will adjust the control output in proportion to that error.
As an example, take the speed of a car attempting to reach a goal point in a straight line. The farther the car is, the faster the car will go, and its speed will reduce as it gets closer. Using the proportional control, we can fine-tune how fast the car will respond to the change in distance.
Integral Control (I)
This component concerns itself with the accumulation of past errors. If the error has been present for an extended period, it will accumulate (integral of the error).
Using the car example again, suppose the car has gotten close enough to the target but hasn't reached it. The proportional control has stopped producing a meaningful output value, but we want the car to get closer. We can increase the integral component, which will allow us to eliminate the residual error (make the car move the final distance to the object).
This is particularly useful if the car is on a hill or there is a large amount of friction. The integral control would allow the car to move closer and avoid rolling backwards in the former case or getting stuck in the latter.
Derivative Control (D)
This predicts the future trend of the error by determining its rate of change. It provides a control output to counteract the rate of error change.
Using the car example, consider a situation where the car is moving quickly and is closing in on the target at a high rate of speed, about to overshoot it. Increasing the derivative control would reduce the control input (speed) to avoid this.