# PID Controller

For the purpose of completeness, we provide a brief description of PID Controller.&#x20;



In the time domain, a PID controller has the following equation:



$$
u(t) = K_pe(t) +K_I\int_0^{t}e(\tau)d\tau + K_D\dot{e}(t)
$$



where $$K_p$$, $$K_I$$, and $$K_D$$ are parameters for proportional control, integral control, and derivative control respectively.

In the state domain, a PID controller has the following transfer function:



$$
H(s) = K_P+\frac{K_I}{s} + K_D s
$$

This is a direct application of the Laplace transform&#x20;

The integral control helps to remove the steady state error; the combination of integral and derivative control helps to reduce the overshoot and improve the transient response to make it faster. There is a very nice video ([https://www.youtube.com/watch?v=XfAt6hNV8XM](https://www.youtube.com/watch?v=XfAt6hNV8XM)) that explains the intuition behind these terms.

The general idea is the following: suppose we want to track a variable, say a car. By tracking, it means we drive side-by-side with the tracked car. Initially, we are behind, in this case, the error is the distance between our car and the tracked car. The proportional term means if the distance is long, we should make more effort (i.e. press the gas pedal more). Imaging we are able to reduce the distance. This means our car is driving faster than the tracked car. At the moment when we catch up the tracked car, the distance is zero, which means the error is zero. At this particular moment, we are not making effort. However, during the catch-up process, our car drives faster. The speed of the car is continuouse so even if we stop making efforts anymore, our car is still faster than the tracked car, which means it will go beyond the tracked car. This is overshoot. To deal with the overshot, a derivative term is added as an offset. In our case, as the distance is reduced, we should make less efforts. The integral term is used to improve the control in steady state. For example, based on the distance, we apply the proportional control, this may make our car drive at the exact same speed as the tracked car. In this case, there is no change in the distance between the two cars so the derivative term is zero and the two-car system is in a steady state and the distance will remain the same forever. The intergral control term represents the accumulation of the error. In our example, the distance and the error remain constant and the error is accumulated. Thus the integral term will instruct the car to be faster and make it escape the steady state.



