FLL 2022: Lever, Lift, Drop, Pull, Align - Programming 3 missions with Kriket box robot M11, M02, M03 - FIRST LEGO League 2022-2023 SUPER POWERED Pro Preview

This is a programming video tutorials. It uses LEGO Education Word Blocks which is the scratch version. We enter into details of how to accomplish missions in a tight spot, how to align the robot and how to make it repeatable.

  • #2257
  • 19 Mar 2024

English

In the last tutorial, we accomplished three missions. Now, I want us to take a look at the programming. As you can see, these are three missions in the same run, and they are quite complex. First, the Oil Platform. Then, the Hydroelectric Dam. We have some turnings. We have a black line we follow. We use the motion sensor. It's quite a complex program, and I prefer if we focus on the programming in a different tutorial because it's easier this way. Let's see the programming. This here is the program for our robot. And the program is not very long, but it's also not that short. Here is the program. And I'll just zoom out so that you can get a sense of the scale of the program. Here it is. This is the whole program. So, we have one main thread with a few additional blocks, two additional blocks and two blocks that are receiving messages. Here is the idea of the program. I'll zoom in to the max. The first few blocks, these are the initialization blocks. So, we have motor C and D that are controlling the attachments. And we have motors E and F that are controlling the motor. And we reset those. We reset to these values that we have for the specific robot. Then, when we start the program, we first broadcast a Lift message. And here is how it works. When we start the robot, we lift the attachment on the front. It's the one right here. And the interesting thing about this Lift is that we are broadcasting a message, but at the same time, we continue with the execution of the program. What this means is that both lifting the attachment and moving forward are executed at the same time. Now, when we broadcast a Lift, here is the part of the program that executes the lift. There is a part of the program that says: when I receive a message Lift, I will start motor C and D in these directions. And I wait until motor C is less than 125 degrees, which is where we want our attachment to be. It's right here. We want to stop right here when the attachment is at the top. And we reset motor D because it might be to a 225, 235. We just make sure that it's at the exact degrees that we need it to be in order to have some consistency in the behavior of the program. This is the first trick in this program: that we use a broadcast message. We broadcast. The interesting thing is that this "move one rotation forward", and "speed of 30" are executed at the same time as this "when I receive Lift". Cool. Now, we continue forward. We moved one rotation forward and right here, somewhere here, at this stage, we start following the line. And we execute this block: "Line Follow For". And here we have some numbers: 710, 30. We have three of these Line Follow For executed one after the other. What are these blocks? These blocks are somewhere here. We have Line Follow For Distance in Degrees, and Accuracy. So distance in degrees, I guess that Distance in Degrees, if a block is implemented like this, means that this is the distance in degrees the motor is rotating. And let's see: we set relative position. Let's make this a little bit smaller. We set relative position of motor E to zero. And we repeat. We repeat these move blocks until the relative position of Е is greater than Distance in Degrees. So, we wait for the motor to rotate to 710 degrees, 90 degrees, 60 degrees. This is how we move the robot. And in this block, we have Accuracy. And the Accuracy basically tells what's the speed at which we want to move because we say "Start moving". And this is not the speed. The speed is already there. This is the start moving. We could set how fast we want it to move left and right, and the degrees to which we want to move left and right. And here we move minus 30 - plus 30, minus 30 - plus 30, minus 30 - plus 30. In this way, we follow the line until we reach a relative position Distance sensor. Let's see the program. We move forward, move forward, move forward. Here, we continue with a different line follow.

Let's see it.

We have three lines follows: 710, 90, and 60. And then, at the end, we stop. We wait for 0.5 seconds. We wait. We are right here. So, we need the three blocks because we have this line that is actually turning left. So, this is why we need these three lines follows. Yes, you can do it probably with one. At the start we are okay if we make sharp turns left and right, but then we have an Accuracy of 5, and then Accuracy of 2. In this way, the robot becomes more repeatable and more consistent, more accurate because we reduce the speed at which it is turning. Then, we stop moving. This here is where we stop moving. From now on, we'll use the yaw angle. What do we do? We set the yaw angle to zero, and we rotate with motor E for 350 degrees. This here. Then, we move back to 0.8 degrees. Here it is. We move back. And then, we broadcast a message. We broadcast a message, and we wait. This broadcast message will lower the attachment. Let's see how we lower the attachment. Here it is. We've lowered the attachment. And now we do a Gyro Line Follow. This is the second block in our program. Gyro Line Follow with a number of 200. Let's see what this number of 200 is. Gyro Line Follow - the block is somewhere here. It's again, Distance in Degrees. Where do we want to go with the robot? We want to go 200 degrees Rotation of the Motor Forward. Right about here. This is what we want to achieve: we want to start from here and we want to move forward. But for this move forward, we use the Gyro Line Follow. We follow a line, an imaginary line that's forward. And this here is the block for the Gyro Line Follow. We've discussed such blocks a few times in the past tutorials. So, just a quick reminder of how it works. It works in the following way: it's the same as the line following. We reset the timer. We set the direction, and the yaw angle. We set the relative position of E, and we start repeating. Why? Because we want to stop when we've reached distance in degrees, when the motor has rotated at least, in our case, 200 degrees. Then, we set "movement speed to". And this here is a nice little formula that tells us how we want to move. What's the speed of the robot along with the timer. So, it's 30 plus timer multiplied by 50. This allows us to control the speed of the robot. And, if the yaw angle points to one Direction, then we move left. If it points to another Direction, we move right. That's it. It's similar to the line follow, but it's following an imaginary line with the gyro sensor. Repeat. We repeat until we move to more than 200 degrees. And here it's important that we have the absolute value of the E motor, and we move with the speed. And this speed is somehow multiplied at the start. What's the purpose of this set movement speed to? The purpose here is the following: when we start with the robot, we don't want to start very fast. So, at the start, the timer is with a really small value, which means that we'll start at, for example, 31% of the speed, which is slow. And with time, we will increase this to like 40, 50. Which means that we will accelerate. And when we accelerate, we keep a straight line. That's why we need this set movement speed to, because it gradually increases the speed of the robot, which gives it a chance to accelerate. And because we accelerate, we have a more consistent behavior. Returning to the program. What do we have in the program? We broadcast and wait. We do the Gyro Follow, and we stop moving. After we stop moving, we move with the motors up, down. Up, down.

And we repeat this, not in a loop, but we've repeated them as blocks. Just as an exercise, we could also build them as a block. But here, we've just repeated the same thing three times. The first time, the second time, the third time. We just repeat the same thing three times. And we can, of course, put it in a loop. After we've repeated it three times, we need to go to the other missions. We rotate.

And we move back. We move back. Right here we lift again. We lift. We rotate. And this here is really dependent on the field that we have, where the missions are. So, there's nothing that interesting here. We just try to get to the right place. We move. We reduce the speed. We move again. Just backward and forward, using the yaw angle, trying to get to the right place.

Now, let's see. And let's stop on the Lower. Where do we lower? Somewhere right here. So, we've positioned the robot in a way that we can lower right here. We say, broadcast Lower and wait. And as we broadcast, we will take part of this mission model, and we should bring it back to base. What you should remember from this program is the broadcast. The broadcast Lower and wait. The broadcast Lift and wait, the fact that we can use the yaw angle, and we can use the Gyro Follow to control the behavior of the robot. And where when we are in a tight spot, it's like, it's a configuration. We should move slightly to the left. Slightly to the right. Slightly to the left. Slightly to the right. These are just inevitable things. After we lower - what we do, we move back, and we wait until the yaw angle is more than 20. Why? Because we want to accomplish this mission at the back. We also want to accomplish this mission. We rotate, and we return back to base. That's it. This program is not very easy, but it's also not that difficult. Hope this is helpful, and I'll see you in the next tutorial.

Courses and lessons with this Tutorial

This Tutorial is used in the following courses and lessons

Image for FIRST LEGO League 2022-2023 SUPERPOWERED solutions and review with Kriket Box robot from LEGO Education SPIKE Prime
  • 60
  • 223:09
  • 20
Image for FIRST LEGO League 2022-2023 SUPERPOWERED solutions and review with Kriket Box robot from LEGO Education SPIKE Prime
  • 60
  • 223:09
  • 20