How do you detect a cross-section and move from following the main line to following the crossing line. In this series of video tutorials we are starting with a very simple solution that could work in most of the cases. It is especially useful for the FIRST LEGO League Trash Trek competition where there is such a section.
- 04 Nov 2015
- LEGO MINDSTORMS, LEGO MINDSTORMS EV3
- FIRST LEGO League, EV3, Light and Color Sensor, FLL, Programming
Crossed lines and T Sections
People generally refer to T Sections as the place where one of the lines on the competition field is crossed by another line. There are ways to detect such sections that involve the user of 5-6-10 sensors. But we do not have that much sensors in the LEGO Mindstorms EV3 set and that's way we must look for other solutions.
Sometimes when you are following a line this line might be crossed by another line and you must detect this and somehow continue following the original or move to the line that is crossing the original line. We would implement in this and the next few videos a very simple program for following a line. Let's say that we come from east and if we come from east then continue south on the intersection between the different lines. This is a very handy program and we received a number of questions from different teachers on how we can implement such a program.
This program could become quite complex it might require, in other robotic system it is solved with the use of, 5, 6, 8 sensors. In this case we have only 2 sensors and we can implement a complex program but we'll start with something very simple. This very simple program will behave in the following way. We move with the robot, we detect the line, we then follow the line for a number of seconds, then we turn and we search for the intersection and we align to the intersection. In this way we know exactly where we are and then we can turn, align here, start following the south line. It's very simple. Just moving for a number of seconds and then try to align and then we know exactly where we are. Let's see how this looks in the program. Here we start with the program that we previously developed for following a line. That's the proportion for following a line. As you can see currently. This program follows the line and it follows the line unlimited. This will continue following the line forever. What we want to do is to follow a line for a number of seconds. Let's say 3 seconds. I think 2 will be better because of the camera and now we want to follow the line for 2 seconds and also we want to extract this whole behavior in a new block.
Why? Because this program is getting quite complex and it will be more readable if we extract this in a new block and we can use it in other programs. I'll select a new variable and it will be called loop time
and I'll read the value of time and I'll pass this value to the loop block. Now we can extract the whole loop block. Select it, tools, My block builder and this will be Proportional follow and we choose a nice picture, finish. Now we have a new block and it is proportional follow. For this new block it contains the whole program for following a line. We want to follow a line for a number of seconds. Let's say 2 seconds. This is our whole program. Now if we double click on this block we'll see the original program for following a line. As you can see there is a parameter here that's pass to the whole program.
Using a block we can make our programs very clear, very understandable and very easy to maintain.
The robot follow the line for exactly 2 seconds.
Now what we should do is after these 2 seconds turn, move forward and align to this line. We should move forward enough so that the other sensor, this one here, the one attached to port 4 moves over the black line and it can the search for the other black line. The line that is crossing the original. Then we align to the line. This would be pretty easy. We just take 2 of the large motors and we want to rotate our right motor in this case motor A and we want to rotate it backward for let's say 50, power, -50 and then for 0,3 rotations. I don't know the exact value so we'll just have to experiment to see what works for this robot. Then move forward with both motors.
We move forward with both motors for let's say 1,5 rotations.
We'll experiment with these values.
Follow for 2 seconds, turn and move. We move forward over the line that is crossing the original, over the second line. So we must modify our program to actually find this line. But we'll do this in our next episode.