For this tutorial however, we will be using a more sophisticated controller known as a PID Controller, specifically a PD controller. Let us look at what a PID Contoller is all about:
PID Controller
In the Bang Bang controller, we made the robot turn a fixed amount in a particular direction. However if we extrapolate the logic used, then it makes sense that the amount by which the robot turns should be proportional to the amount by which it has deviated from the black line. The further the center of the robot is from the black line, greater should be the amount by which the robot should turn to return its center on the black line.
Such a control logic is employed in a Proportional Controller, in which the control signal is proportional to the error signal. The Proportional Controller corresponds to the 'P' part of the PID Controller.
Depending upon the proportionality constant, the amount by which the robot turns for a particular value of the error signal will vary. This constant of proportionality 'P' is a parameter of the model which has to be tuned as per the application.
One limitation of the Proportional Controller is that the robot can continue oscillating about the black line due to inertia. In this situation, the robot will continually oscillate about the black line while moving forward and will not be able to accurately follow the black line.
One way to dampen the oscillations so that the robot returns to the black line quickly is to add a derivative component to the control signal. In this case we compute the instantaneous derivative of the error signal which would serve to dampen the oscillations. A constant is multiplied to this derivative and the product is added to the control signal. This constant is known as the derivative gain and corresponds to the 'D' part of the PID Controller.
In the model, the block labelled 'PID Controller' represents the controller described above. You can view the values for 'P','I','D' by double clicking on the block.The example model already has some default values for 'P' and 'D' while 'I' is equated to 0. For an alternate explanation for the PID Controller, check out this blog post which provides a great analogy to explain the PID Controller using pendulums.
One method to tune the PD Controller without using a mathematical model of the robot is listed below:
- Adjust the proportional gain of the controller till you obtain a suitable response.
- As a thumb rule, set the value of the derivative gain to be equal to 1/10th of the proportional gain.
- Now adjust the derivative gain and observe the change in the robot behavior, till a suitable behavior is obtained.
- Increasing the proportional gain will increase the amount by which the robot turns.
- Increase the derivative gain will dampen the magnitude of oscillations by the robot.