Robo Tank Line Follower

Creating a robot that is able to follow a line (dark line on a light surface or vice versa) seems to be the MyFirst  or the “Hello world!” of robotics.

Intrigued by the notion, here I will describe to you my first “line follower”, built with Mindstorms EV3.

For my job as an ICT and Computer Science teacher I am investigating into and experimenting with LEGO Mindstorms, later I will have a look at LEGO WeDo as well. These are initiatives of the LEGO company and the Massachusetts Institute of Technology (MIT). Read more about Mindstorms at MIT and WeDo at MIT.

Stay tuned, more will follow.

My first line follower

First, let’s have a look at it’s performance:

 

Program description

The Bot

The program is written for the Tank Bot that has two threads and one light sensor front center. It also has two kill switches on top to be able to perform an emergency stop when things go south.

Start and calibration

At the start of a run, the light sensor must be positioned exactly half over the right edge of the line and half to the right of the line. This positioning is important, because the program start with a measurement that determine the average between light (the floor) and dark (the line).

Workings

From this calibration average, deviations are calculated – an upper and a lower limit – to be able to determine wether the bot has to steer left (towards the line) or right (away from the line). The deviation has been set to be 3% up or down from the average calibration value.

 

Initialization

At the start of the program the bot gives a couple of startup sounds, the variables are given their initial values, the light sensor is calibrated and the upper and lower limit for the light intensity are calculated:

Initialization
Initialization

 

Main program

After initialization, two loops are started that will run parallel:

MainLoop:

MainLoop

  • measure the light intensity;
  • calculate new motor values:
  • when intensity it is over the upper limit, make the bot steer left towards the line;
  • when it is under the lower limit, make the bot steer right away from the line;
  • when it’s between the limits, make the bot steer straight;
  • feed the newly calculated values to the motor
KillSwitch:

20161113_201_killswitch

KillSwitch will:

  • see wether one of the killswitches is pressed
  • if so, terminate the MainLoop and end the program

 

In conclusion

Not bad for a first try. It’s a little rough around the edges though. The corrections are course, the bot tends to zig-zag a lot. In a next project I will look at the mechanics (perhaps it’s the threads) and at the programming.

 

Leave a Reply

Your email address will not be published. Required fields are marked *