In addition to Line Following, lines on a FLL Robot Game map can be used for Line Detection. Using a Light Sensor, Line Detection is a very effective technique to consistently navigate a robot to the right location. Line Detection is not limited to the regular white/black line strips; it can also work for other shapes where reflection light changes can be detected.
We used Line Detection a lot for FLL Robot Game. In this post, we’ll provide a step-by-step guide on creating a reusable My Block for Line Detection.
The following edge detection logic is used.
1. Turn Motor Power on
2. Wait for a white line using Wait Block.
3. Wait for a black line. using Wait Block.
4. Loop 2 & 3 for the number of lines to detect.
5. Turn Motor Power off
Based on the above logic, the Line Detection program is shown below. Using the color senor on port 2, the program will move our robot at power 35, detect the white/black line strip once, and stop. The Wait Block The block stops waiting when the threshold comparison is True. The first Wait Block stops waiting when the light sensor’s reflection reading is greater than 80% (white). The second Wait Blocks stops waiting when the light sensor’s reflection reading is smaller than 20% (black).
Creating a Reusable EV3 Line Detection My Block
Now, let’s convert the above program into a reusable My Block!
Enter My Block name, description, and select an icon.
Add the Port parameter for the light senor which will be used for line detection.
Add the White Reflection Light parameter to wait for the white line or bright area.
Add the Black Reflection Light parameter to wait for the black line or dark area.
Add the Count parameter for how many lines to detect.
Add the Power parameter for the Move Steering Block then Click Finish.
Finally, connect the data wires.
Using the Line Detection My Block
The following map is for 2020 RePLAY season. From the start position, the left My Block will make our robot travel with 35 power until the port 2 Light Sensors detects the first line. The right My Block will make our robot stop right at the 4th line.
Using Line Detection for 2019 CITY SHAPER Bridge Mission
For the 2019 CITY SHAPER Bridge Mission, we wanted to move our robot right onto the flag to raise them. To precisely moved our robot there, we found that there were patterns on the Bridge that we could use for Line Detection as shown below.
Initially, we aligned our robot with the bridge by using Line Following on the line leading to the bridge. It’s important to align the robot with the bridge accurately. However, how close the robot is to the bridge isn’t as important. Regardless of where the robot started, we utilized Line Detection to enable the robot to halt consistently at the second line.
As you can find, they aren’t actually lines. But the light reflection changes between the gaps can still be used for Line Detection.
The following screenshot is the last part of the program for the Bridge Mission. It used Line Following My Block to align with the Bridge model, used Line Detection to stop at the second line, then used the Move Inches My Block to move the robot on to the flags.