Our next assignment was to build a Lego vehicle that followed a tape line on the floor. We re-partnered up, and me and Briana got to work. The first part of this assignment was to build the vehicle. This time our robot could have wheels, which made things much easier mechanically. However, when we added the light sensor, we quickly discovered that we needed to place it high so it doesn't get in the way of other things like motors and wires from the motors. This made our robot a bit unbalanced and it was also somewhat hard to maneuver. We had a 2-motor limit so we thought adding a third wheel in the front was out of the question. However, a little exploration led us to a small ready-made front wheel mechanism that could be attached directly to the NXT. This addition made it easier for our vehicle turn but it also presented some difficulties of its own. It wasn't getting enough traction so it was ineffective at first. Also, our first programming efforts revealed that our light sensor was too far away from the ground to get an accurate reading of light values. We changed our design to fix these problems and, with Lyn's help, got a well working robot. We learned that before you can program the robot, you need to make sure that it is physically capable of doing the motions you ask from it. Mechanics first, intelligence second.
![]() |
| First Robot |
![]() |
| Line Follower.2 |
![]() |
| Our First Code |
Then, we started to think about ways to make our robot find the line and follow it. We first wrote a code that shows the light levels on the screen of our NXT when we put it on the ground. This told us that the tape was 37-40. The floor was darker in color and the readings were 31-34. We decided to make one of the wheels always go forward and the other go forward or backward depending on the light value. The idea was that the robot itself would turn in a circle until it found the line reading of 38, then it would keep going until the reading changed. Then the circling would begin again. This seemed like a reasonable way of moving as the line would be never too far away. However, when we actually put our vehicle on the not-so-straight line we prepared, we saw that we had a few problems. Firstly, the robot needed to be placed very close to the line or it would never find it. The light sensor had to sweep the line when it rotated. This made the line following a very small part of the vehicle’s total movement as it kept turning and turning. We also realized that even though it did scan the line, sometimes it would keep going for a second too long and miss it, due to the time it takes for the program to be executed. This was also visible when the line curved to one side or another. One side was easy to detect, while the other took a complete rotation to find. All of these difficulties called for adjustment.
| Our Code for Reading Light Levels |
We were puzzled on what to do next because our program had worked but not in the way we wanted. There was no bug in the programming or an error in mechanical design. Our idea was not efficient. We needed to come up with another way of finding the line and following it. We talked to Lyn, which led us to be convinced that a sweeping motion would be the best way to move. Almost everyone in our class was already using this technique and it was working for them. We agreed to try this method and met outside class because we had to have our line follower functional by the next class. We wrote a new code using the light value at the edge of the tape, 34. We made our vehicle move with the sensor on the edge of the tape. It would constantly go a little right and then a little left and then right again, by the alternation of forward and brake on both of the wheels. The motion depended on the light values: the vehicle would change direction when it realized that it was off of the tape. Our robot wasn’t bound to the line anymore; it would keep sweeping and going forward until it found a line when placed somewhere distant. However, we observed that the line following didn’t work if the robot approached the tape from the right side, due to the starting moving/non-moving designation of the motors. We had to keep this in mind when we put our robot into starting position. One other change we made was to lower the power so that our robot had time to respond to the light values from the sensor. This produced a much better line follower.
| Our code after the adjustments |



No comments:
Post a Comment