Line Tracker

I have a project due in few weeks. The idea of the project is that the LEGO mindstorm has to follow a black line on the floor.

So I started thinking about this problem and my initial approach was the following: I assume my robot starts ON the black line. So it starts traveling forward and continues until it finds white (which is the floor). At this point it has to turn but which way? To the left or to the right? Perhaps it picks either one of those in random (LEFT or RIGHT) and tries to find black, if it can’t find black it turns again and hopes to find black in the opposite direction (otherwise it’s completely lost).

This process seems overly complicated and extremely un-reliable. More importantly if [this is not required in my project] mindstorm had to go the finishing line in the earliest possible time then the above approach would certainly fail because it would have to search the black line as opposed to follow the black line.

So I had to think of a different approach and I came up with the following: Follow one of the edges of the black line (rather than the whole black line). Even before starting to think about this problem I started to see some of the program’s benefits. So let’s say I choose to follow the right edge, then the robot should look to the left for white and right for black.

Very elegant. The robot would either to make a right or a left. If after turning a little (let’s say 5 radians) it finds black it continues to turn in that direction until it finds the edge and then continues in that direction.

I am currently working on the latter algorithm and will soon post the C code (actually NQC code) for you guys.

Leave a Reply