It sounds great in theory, but what about the practice? For some robotics enthusiasts a project such a robot able to detect and follow a line doesn’t count too much, while for some beginners such a project is the one that will never forget. For new initiates it’s the first profound step into robotics, and rightly so, it’s should be the best possible project.
Even you’re a maker with a lot of experience in robotics aiming to build the best possible follower robot or re-build the old one, even you’re a beginner without too much hours spending to solder wires and write code, in this article you can find five techniques applied for a line follower robot combined with different technologies and different ideas. All these techniques can be applied at home even is the first time when you use an Arduino microcontroller, as well as if you have to remove the dust from your old line-tracking robot.
In general, a line tracker bot is an autonomous robot designed to detect and follow a visual line painted or embedded on a particular surface, or an electric wire embedded in the floor. The goal of any maker is to engineer a robot able to keep the center of the line. Depending on different variables and technologies that go into the design, the robot can have different behaviors. Yes, this means the bot should have the right sensors and controller to put the robot into the right place.
To have a clear image over the methods and technologies used to build a tracker bot, in this article I explore five of the most common techniques together with the best ideas and implementations.
1. Using infrared sensors to distinguish a black line from a bright surface
We have a line, preferable black, and a robot platform that allows us to be creative and write the program to detect the black line on a giving area. This is the problem, and we have to find a solution. To get the effect we want, the preferable solution in this case is to use an infrared sensor. This sensor type can distinguish a bright object by a dark object. The following technique is very common in robotics competitions where teams of young engineers have to build fast the best line tracker robot.
The robot is equipped with photosensors able to detect the position of the line which in turn determines the robot position. The photosensor output varies depending on the intensity of radiation striking the material based on the concept that a white surface reflects the light, while a black surface absorb it.
To avoid the interferences from the visible light that surround the robot, the best option is to use the properties of infrared light. The infrared light is emitted of course by an infrared sensor able to detect the intensity of reflection. The output voltage of the sensor is corresponding to the intensity of the light received by the sensor. The output voltage is compared by a comparator circuit with fixed references and is translated into logic values such as 0 and 1. With these values, we’re in the heart of the problem when the controller uses it to take decisions and make the robot to stay on track.
Rather than starting to build from scratches a tracker bot is to get inspired. If you take a look at the project presented below, you’ll notice how simple is to build a robot based on Arduino microcontroller and QRD1114 infrared reflective sensor.
There are no rules to use the same platform as in example, and you’re free to use any infrared reflective sensor with any mobile robot. Only you have to take account is the properties of the sensor and how to setup the sensor.
The QRD1114 infrared reflective sensor is prepared as an exclusive version of a line-tracking robot. By keeping the sensor bent downwards facing the ground, it should detect with accuracy a black electrical tape.
2. Using light dependent resistor (LDR) sensitivity to light and white LEDs
The following technique uses inexpensive LDR sensors to build a robot able to follow a black line on a white surface. The real hard problems with this technique are improving the performance and the effect of light over the sensor measurements. The costs…are at the lowest level possible. An LDR sensor used in the project below is around 1EUR.
To complete the task, we put the light at work to find the line and keep the robot on the right track. In darkness, the resistance of the LDR sensor becomes high, while in light the resistance returns low values. Regarding the resistance, it can vary from a few ohms to kilo-ohms or more. Based on the values returned by the LDR sensors, the controller decides the position of a line and controls the motors establish the required direction.
Why we couldn’t ask the robot to detect the line and then keep track on it? It sounds science fiction, but till then, we have to suit our needs and use simple LDR sensors to detect a black line. To have the best results, we have to be creative and creates pairs with LDR sensors and LEDs to cover an area larger than the black line. If you code it right and make the difficult combination of LDRs and LEDs, the detecting system is ready to keep the robot inside of the black line.
Now, take your microcontroller or single board computer, the LDR sensor together with LEDs, a mobile platform and start building piece by piece the line tracker robot. The steps and fundamental aspects are explored in the project below in order to know what you are doing and how you’ll do.
3. Using infrared LED and photodiode
This detection system based on infrared LED and photodiode has a lot of capabilities, but you have to keep in mind their limitations. Things like combining the IR LEDs with photodiodes and the varying lights are important to consider.
The detection system works based on the distinction capability between white and black, between a white surface and a black line.
The most sensitive part of this project is the combination between IR LEDs and photodiodes. In the project explored below, the maker uses a mini breadboard, which definitely was the best price and is the quickest solution. As a hint, the detector could have strange behavior if the LEDs and photodiodes are not at the right distance from each other.
4. Using PID algorithm and IR sensor
Using PID (Proportional, Integral and Derivative) algorithm to control a tracker bot can produce fascination in the results if all the parameters are perfectly managed, but if the parameters are completely wrong, most probably will produce some sleepless nights. The algorithm forces you to focus on controlling a particular physical/electrical quantity in order to achieve a set value called the ‘set-point’.
In this case, for a line tracker robot, the controller has to calculate the amount of robot deviation from the center of the line. This will go a long way to control the speed of electric motors to keep the robot on the right track. The algorithm is based on three constants (Kp, Ki, and Kd). The constants are the shortcuts for proportionality, integral and derivative. All these three constants have to be set by the maker after experiment with different values and preliminary tests. Soon, you’ll be able to predict how good your control algorithm works.
You might be thinking “How do I start?”. The first step in implementing a PID algorithm is to calculate the difference of the set-point (the value of your goal) and the current value. For a line-tracking robot your goal is definitely to have a bot with the middle sensor right on the line. This position is your set-point value.
The current value is the position of the robot at any time. For example the position of the robot when running for the first time. The error mentioned previously is the difference of these two values.
To reach the point when you have to adjust the speed of the motors, the error has to be multiplied with the three specific constants (Kp, Ki, Kd).
Why this effort with constants and tests? The following technique is the shortest way to have a robot that follows a line smoothly and without oscillating on both sides of the line. More than that, the battery power is conserved and the robot follows the line much faster than the conventional techniques.
- Initialize the set point S.P
- Read sensor data P.V
- Calculate the error e(t)=SP-PV
- Calculate the output of the PID controller u(t)
- Apply controller output to the actuators
- Go back to step 2
This algorithm can be applied in practice in different ways. One simple way is to get inspired by the following project where a wheeled robot is controlled via Arduino Clone, while the input comes from a Pololu QTR-8RC sensor array.
5. Using Android Smartphone and Computer Vision Software
For makers, a smartphone is an elephant when it comes to build smart robots. We cannot ignore the multitude of sensors, the powerful processor, wireless communication options, the battery, and several other features that can be used on everything in robotics.
One possible scenario where a smartphone satisfies the necessary power to run applications and PID algorithm on each frame could be:
- grab frame from camera
- convert the frame into grayscale from YUV format
- threshold the image and set the white and black pixels
- scan the image and set the largest area with dark pixels
- set the middle of the black area and compare with the center of the screen to result the error value
- use PID algorithm to calculate the speed of the motor
If you use an Android smartphone, you have more time to experiment other aspects of design with an application called LineTracker specially designed to implement PID algorithm in a line follower project.
Before diving into an example, I have to add the communication with the Arduino microcontroller where another application is used – the Amarino. The Amarino toolkit allows you to interface the smartphone with Arduino microcontroller using the Bluetooth module.
Below, you can use for inspiration a robot tracker that uses a Motorola XT720 smartphone to capture video and run the algorithm together with LineTracker and Amarino applications.
In The End…
You have to believe that you should be able to design and build at any moment your wished tracker bot. Your argument should be the creativity that completes the work of other makers.
I want for my users to have a great experience with almost any possible application and any device that can be used, as well as all possible technologies that can be used to achieve your goals in tracking.
If you plan to build a tracker robot or you already have some experiences, please use the comment section and feel free to share your experiences.