Once we have the error signal we can decide how to move the Zumo Robot so that it stays on the black line. The signal sent to the motors to ensure that the Zumo Robot stays on the black line is called the 'control' signal. The function or component which generates the control signal is known as the controller.

learn_arduino_Zumo_line_Forward.png

learn_arduino_ZumoLineRight.png

learn_arduino_ZumoLineLeft.png

The simplest controller is illustrated in the figures above. The logic being: if the Zumo Robot center is to the left of the black line, then turn right by a fixed amount so that it eventually returns to the black line. Similarly, if the Zumo Robot center is to the right of the black line, turn left so that it returns to the black line. This controller is known as the Bang Bang Controller.

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.
The 'I' part of the PID controller is not used for this particular application. Thus specifically, this controller is known as a PD 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.
Tuning the PD Controller

One method to tune the PD Controller without using a mathematical model of the robot is listed below:

  1. Adjust the proportional gain of the controller till you obtain a suitable response.
  2. As a thumb rule, set the value of the derivative gain to be equal to 1/10th of the proportional gain.
  3. Now adjust the derivative gain and observe the change in the robot behavior, till a suitable behavior is obtained.
  4. Increasing the proportional gain will increase the amount by which the robot turns.
  5. Increase the derivative gain will dampen the magnitude of oscillations by the robot.
Try tuning the PD Controller shown in the model to see how the change in parameters affects the behavior of the robot.

This guide was first published on May 19, 2014. It was last updated on May 19, 2014.

This page (Process sensor data using Controller) was last updated on Mar 28, 2021.

Text editor powered by tinymce.