Monday, January 10

Line Following

Continuous Line Follower
   Following a line...  An idea that to the extreme beginner and the expert seems easy, but to the middle class of programmers (those who understand the basics and essentials of programming, but have not mastered the art,) the task is quite complicated.  Most of the line followers I have seen on NXTLog and elsewhere follow continuous lines.  A few of them have the capability of traversing cross-roads and road split.  And one or two can cross breaks in the track and avoid obstacles in the way.  I have seen multiple light sensors on a single bot and have observed but one on a bot.
Four Light Sensors
 I think there are definite downfalls and gains to be had from either of the two; on the one hand, more sensors mean more accuracy but is more expensive; while on the other, when using only one light sensor, you don't need to buy extra parts but the robot will be slower and less accurate.
  There are many other alternatives to the methods of line following described above, one being to buy non-lego sensors for your robot such as the five sensor array below.  One alternative that I have thought of is to have a light sensor mounted on an arm or boom and swing back and forth in front of the robot.  The light sensor would detect the line edges and, depending on the position of the servo controlling it, the NXT could tell how hard to turn, and what direction to turn. 
   The algorithm used to decide the turn would run something like this.
   
#define RIGHT true;
#define LEFT false;

{  // when pointed straight ahead, the rotation sensor is at zero.
  int turnpct = degrees / 2;

  if (degrees > 0){ direction = RIGHT; }
  else if (degrees < 0){ direction = LEFT; }

 
RotateMotorEx(BC, 100, 90,
     turnpct, true, false);

}// I have not tested this algorithm.
  //I made it up as I was sitting here,
  //but it is something like that which you would use.

The GreyHound
I recently discovered a project on NXTLog that uses this mode of line following.  It is a simple bot named the GreyHound built by hydrogenhead.
  The main advantage of such a design is:
   Although a little slower than using multiple light sensors, the 'sweeping' method is much more accurate, providing the ability to get a reading on every degree that the motor controlling it is able to turn to. 
  For example, say that we have four different light sensors across the front of our robot similar to what we see in the third picture up.  We could get four readings. We could vaguely tell how wide the line is, and generally where it is in respect to the front of the robot.  Now let's say that the line our robot is trying to follow is wide enough to fit one light sensor.  The robot randomly picks one of the middle sensors (we'll call it Jared.)  Now on following the line, the robot tries to keep the line under the chosen sensor (Jared,) and when Jared losses the line, the two other sensors start checking for it in order to alert the NXT as to where it is.  On receiving information as to the direction the line has turned, the NXT gives the appropriate information to the drive motors who respond accordingly.  This sounds great, but there are two problems to this method.  If the line turns too sharply, the robot loses it, and upon adjusting the turn radius, the bot follows the line in zig-zags thereby considerably reducing its speed.
 
   If we use the sweeping method however, our results are much more promising.  The light sensor (we'll continue using the name Jared for familiarities sake,) goes back and forth across the line, stopping precisely at the edges so as not to get confused with any other lines that may be in the near vicinity.  Every time Jared gets to one edge of the line, he informs the NXT, who in turn, gets the motor degrees from the motor moving Jared.  After receiving two such motor positions, the NXT finds the average, ( the middle of the line, ) and adjusts the turn percent accordingly.  When our robot comes to a corner, it slows down so as to not overrun and get lost.

   To sum it all up, the sweeping method of line following is slower going in a straight line because of the time taken to move the sensor, but because of the added locations possible for the sensor to be in, the robots precision is greatly advanced and therefore the speed and smoothness in traversing curves surpasses greatly the performance of other robots.

No comments:

Post a Comment