We've detected the gap. It's time to move over it. This is difficult because we have to detect where the line is after the 0.1 meters gap on the line following field.
- 17 Feb 2016
- LEGO MINDSTORMS, LEGO MINDSTORMS EV3
- FIRST LEGO League, Line follow, The Arab championship for robotics - Line Tracking, EV3-G, EV3, State machine, Light and Color Sensor, FLL, Programming
We would add a new state with a new behaviour (transition between the states). The state will be called "Gap" and we enter this state when we lose the line. The behaviour (transition) is moving over the gap until we reach the new line.
Make sure you understand light/color sensors and line following. Take a look at the following courses:
Courses with this episode
The episode is used in the following courses where you can find additional tasks for it to use in class
Make sure the class understand the program by doing the following tasks in class and STEM course:
Tasks description, submission and evaluation are available to subscribed users.
Subscribe now to access the full capacity and get feedback.
We stopped at detecting the gap. Move, lose the line, detected the gap. Now we'll move over to the next line and continue following the line.
This here is our program and in this program we have the 2 main parts of the program. First calculate the state and then executing something depending on this state. Now I would like to group some of these blocks together. And we want these 2 blocks. What we do here is detecting the gap. If we are following a line or detecting a gap. So I add a new My block and it will be called CGap (Check Gap)
but first we must select these 2 blocks. Then we call it CGap (Check Gap) and it accepts only one parameter. This parameter is the sensor value and icon for this parameter is an integer.
So this here is our program now, much more simple and I'll turn it to a flat view. We have the following states, first we'll check if we are on a gap or follow a line, then if we are in state 0 which means follows, we just follow a line, if we are in state 1 we must somehow move trough the gap. Here it's a number of a motor movements, for example, we have stopped and then I would like to turn back with motor B, our right motor, I just turn it on in a reverse direction and I do that until we detect a black line. So we are returning and aligning to our black line. This will be for sensor, we want to detect with sensor 2 a black line. Not only with motor 2, which is the middle sensor, we also want to detect, the black line with the right sensor, so that we can align to our line.
This whole behavior here is, detecting the gap and moving through it. After we detect the line with both sensors, we stop motor B,
then we rotate the whole robot to 90 degrees and this means, for this particular construction, we must rotate motor B for approximately 1 rotation forward, then we just move with both motors, forward for, let's say, 0.5 rotations. These are approximately 10 cm and this is our behavior for moving through the gap. It's just simple movements with different motors, we stop the motors, we turn back until we align to our black line that we have just followed and lost, we stop, we turn left and we move forward and we move over the gap. This here is the block that moves over the gap. Let;s see how our program works.
The robot follows the line, loses it, wait for about 5 sec and then we continue following the line.
This is the program with which we can pass through this gap.
A few more modifications before we can continue with our next video. A few final changes to our program. Our whole behavior here is actually moving through the gap. I'll build a new My block and I'll call it Pass Gap.
There are no parameters it's just a procedure, finish and this is how the program looks. Let's see the whole picture again.
We have our second sensor, the one on port 2 and we detect, then we check if it's a gap or we are following a line. If we are following a line, we are in state 0 and we follow a line, but if we are in a gap, then we are in state 1 and we must pass it and at the of this Switch we just set the state to -1 and we loop the whole thing. Now what we must do is add different states for turning left and right. Let's do this in the next video.
Курсове и занятия включващи този Урок
Този Урок е използван в следните курсове и занятия.