Friday, March 16, 2018

Line Followers

I'm not sure what it is about our robotics group this year, but I have never seen such a wide diversity of approaches and solutions to problems before. At BMS the teams are working on "line-follower" robots. The challenge is to create a robot and accompanying program that follows a serpentine, black line from start to finish. The fastest robot to complete the course is the winner. 
We introduced this challenge by discussing the basic algorithm for line following. This method uses Reflected Light Intensity (RLI) to follow one edge of the black line. Using the port-view utility on the EV3 brick, the sensor is held over the edge of the line, half on black, half on white. This value is the target RLI. When the reading is equal to the target, the robot goes straight. When the RLI increases, the robot turns back toward the black line, when the RLI decreases, the robot turns away from the black line. The program below, created by a 6th grader, is a simple and effective method for following the line. This student's robot was the first to finish the course.

It says that if the RLI is less than 30% (the "yes" case of the switch), then the robot will turn 40% to the left at 35% forward power. If this case is not true and the RLI is greater than 30%, the robot will turn 40% to the right at 35% power. This switch is placed in a loop, so the program will continue until it is stopped by the operator. The robot shimmies back and forth with this program, continually seeking the target RLI value and adjusting tens of times per second. 

For the first time ever, a 7th grade student decided to abandon the "move steering" block which controls two motors simultaneously with a built-in steering algorithm. Instead, he chose to create two programs in parallel, each controlling one motor. In order to do this, he used two light sensors, physically separated by the same distance as the width of the black line on the course. Each sensor is aimed just on the outer edges of the line. His program is below.

Instead of using a switch, this student is using the raw reading from each light sensor to control the power of a motor. The yellow lines are called data wires, and send numeric values from one block to another. If the sensor reads lower, then the corresponding motor moves more slowly. If the sensor reads higher, then the corresponding motor moves more quickly. He is changing the amplitude of the light sensor reading by -50% (multiplied by 0.5), so if the RLI for sensor #3 is 50%, motor B will run at 25% power. Effectively, this student has written his own steering algorithm controlled by the continually changing RLI readings of each sensor. This program is still being developed, and I suspect this student will play with the amplitude value in the red math blocks to find the ideal balance between speed and accuracy. 

The program below was created by an 8th grader, and it uses data wires, math blocks and variables. This robot also uses two light sensors that straddle the black line. Instead of using two parallel programs though, this robot uses raw RLI readings to inform the case of a switch. Then, those same raw values are used to define the values for variables which control the powers in a move-tank block controlling motors A and D. This program is working, but the robot moves quite slowly. This student may also add a math block to change the amplitude of the power output to the motors.  
It's obvious to me that these students are beginning to move beyond my level of sophistication! I plan to do some more reading and practice on my own to better understand the concepts they are exploring. It's exciting to watch their solutions unfold in ways we hadn't imagined.