Tuesday, March 1, 2011

Line Follower: Day 1—2/22/11

Today we started our third project—building a line follower.  Our challenge was to create a robot that could, without any outside assistance, successfully follow a line of tape on the floor or a table using an LED light sensor.  We were to do this by creating an NXT robot with two motors, no more than two large wheels, a light sensor, and whatever other Lego parts we wanted, and then using LabView to write a program that would allow our creation to successfully follow the line.

After receiving our assignment, my partner and I headed over to the Lego table to begin building our physical model.  We attached a motor and one large wheel to either side of the NXT, one small wheel to the front for support and maneuverability, and attached the light sensor so that it protruded out in front of the rest of the vehicle.

Our first model
We decided to try to make our line follower follow a line of white masking tape on the gray floor, and brought this first model over in order to take preliminary light readings.  We quickly discovered various weaknesses in our design.  First, the light sensor itself was too far above the ground to take an accurate reading—the area the LED sensor covered was too large to be able to quickly and successfully distinguish between the light tape and the darker floor.  Second, the large wheels were positioned too far behind the vehicle, thereby making maneuvering less accurate and potentially creating a problematic center of gravity.

We took these factors into consideration and headed back to the Lego table.  With regards to our LED sensor, we wanted to make sure that it was as close to the ground as possible for an accurate reading, stable, and far enough forward that its readings would not be blocked by the rotation of the small wheel.

After much tinkering, here is the much-improved fruit of our labors:

Model #2
LED attachment close-up
After successfully building our model, it was time to move on to the real challenge—figuring out how to use LabView to make our creation intelligently follow a line.

Our first idea was to have one wheel perpetually going forward, and the other rotate forward or backward depending on the readings from the light sensor.  Our hope was that the adjustments of the light-dependent wheel would turn our follower as necessary in order for it to follow the line.  We took our creation to the line of tape on the floor to make light sensor readings, and discovered that the tape reading was about 37-40, and the floor readings were about 31-34.

Early Code
The idea of this code was that our robot would rotate until it found the line (light sensor reading of 38).  When this happened, both wheels would move forward, sending the robot in a straight line, until it found the floor (light sensor reading of 33) and began circling again to find the line.


This code has many problems. First, the circular motion in the beginning means that our robot will not be able to find the line unless it is within rotating distance (see movie).  Second, and more importantly, we had programmed our robot to simply go straight whenever it found a line.  This strategy would not work, because unless our robot happened to be angled exactly along the line, it would be sent in a straight line away from its goal line, since the LED sensor takes some time to process readings.  This factor, combined with our robot's inability to find a line more than a rotation away, was a recipe for line following disaster.


Watching our program's results and listening to Lyn's words of wisdom easily convinced us that we would need to spend time developing a robot that followed its line using a sweeping motion.  Doing so would give our robot much more calculated movements, and allow us to ensure that it moved in the correct direction.

No comments:

Post a Comment