In this video tutorial we demonstrate a really important concept for FIRST LEGO League competitions - you position the robot on the field with depending on timers and rotations. The issue with moving the robot for 10 seconds and then stopping is that every time it is in a different location. Same for rotations. The wheels will slip, the battery will change, something will happen and the robot will not be in the same place every time. This is not consistent and reliable.
- 08 Aug 2022
- LEGO Education SPIKE Prime
- Scratch, Line follow, Light and Color Sensor, LEGO Education SPIKE App Word Blocks, Sensors, Programming, FLL
Why times and rotations don't work?
When we program the robot to move for a number of seconds the robot will arrive at a different place every time. The difference will be larger the longer it moves. Try it. Experiment it. Or if you are here at FLLCasts you know that this is true because this is what you are trying to find a solution for. The robot is not reliable when we use times and rotations. The wheels slip and a difference of even 1cm or about half an inch will prevent us from completing the mission successfully.
How do we fix this?
We program the robot to stop when an even occurs and this even is generally when there is an intersection on the field. In this way it does not depend on times and rotations but on an even, and since the intersection is always at the same place on the field we will always stop at the same place on the field.
How to use the tutorial?
Try to implement the program from the tutorial and try to follow the line
In this video tutorial we use the LEGO Education SPIKE Prime and program the robot to stop at an intersection. What does this mean? We follow a line and we stop when we detect another line on the right. Why? Start, move forward, follow the line until we reach an intersection. And the reason why we want to do this, and it's extremely important here is that in this way we do not depend on timers and we don't depend on rotations. We can start the robot from anywhere and it will stop at exactly the same place, which is the intersection. We can start it from the base, we can start it from another line, the wheels could slip, doesn't matter. The robot arrives at the same place and it stops at the same place. Let's take a look at the program. The program looks in the following way. We have the blocks on the left and again we have the recording on the right. We set movement motors to A and B. So these are the driving motors of our LEGO Education SPIKE Prime robot for our FIRST LEGO League competition. And we set movement speed to 30% and generally we can experiment with 20, 30, 40, depending on the speed that we want. And then what we want to do is we want to move with the robot until sensor F detects this black line. This is our goal, to stop at this intersection. So we move until we detect this black line. And the really important part here is that we are not programming the robot to wait for a number of seconds to reach the intersection or to move a number of rotations to reach the intersection. No, we are moving forward, following the line, then turning until we reach the intersection and until we are sure. And we can even take the robot with a hand and stop it while we are moving and then release it. And again it will stop at the same place because it does not depend on timer or on rotations, it depends on us reaching the second line. Really important concept. You should definitely use it any time you have a chance during competitions. Now, how does this block work? It's a repeat until block. What we are doing is the following we are repeating something until sensor F sees color black. So sensor F is now on white, green is again not black. And the only black that we see will be right here. Right here. And when we are moving, we are following the line. How do we follow the line? We've discussed this algorithm, it's a simple follow a line where with sensor E we detect the color and if the color is black, we move slightly to the one side, if the color is white, we move to the other side. And this values here, you can experiment with them. The smaller the values, the smoother the turn, the larger the values, the more sharp the turn is, which depends on how do we want to follow the line. Do we want to follow the line in a more smooth way or we want to follow it with sharp turns. And this pretty much depends on the line and the turns that we have to take when following the line. How does this work? We start, we follow the line. You see that these are kind of like sharp turns. Left, right, left, right. We follow, continue following until we reach this black line right here where sensor F detects the black line. And then we stop and we exit the program. Let's start the program again, this time from a different place. We don't have to start it from the base because we do not depend on the number of rotations the motors are making or the timer just to wait for the event to occur. In this event is am I seeing a black line with my right sensor? Yes. Then stop again. We repeat and then stop. That's it. What you should do now with this tutorial, you should definitely experiment with this. Download the program and try to program the robot in a way that it follows a line and it stops at the first intersection. Really important concept that is very useful. And it's one of the steps that is needed here to make consistent and reliable robots with which we can have much more fun. Rather than wondering why is the robot not working, what can I do? What we can do is use sensors. And we can use the sensors in a smart way. This specific tutorial line stopped at the intersection. See you in the next tutorial.
Курсове и занятия включващи този Урок
Този Урок е използван в следните курсове и занятия.