В момента ресурсът е наличен само на английски

FLL 2022: Programming Drop, Pull, Lever, Collect, Deliver - 5 missions with Kriket box robot accomplishing M14 Toy Factory, M05 Smart Grid, M06 Hybrid Car, M07 Energy Unit retrieval Pro Preview

In this video tutorial we look at programming the Kriket box robot to accomplish 5 missions. It is a long program for a long run that's why we are dedicating a separate tutorial. We are using LEGO Education SPIKE Prime Word Blocks app.

  • #2233
  • 06 Feb 2024
  • 17:13


In this tutorial, we will enter into more details of how to program the robot to accomplish five missions. And these are the missions from the FIRST LEGO League 2022 SUPERPOWERED. We have a run where we accomplish five missions. And I really don't like it when the tutorials are getting very long because after the tutorial is over, we explain the programming. So, this time we decided to split this into another tutorial, into a different tutorial where we focus only on the programming part. How would the robot move and accomplish all of the five missions in a single run? Let's dive into the programming. This here is the program. It's a program from LEGO Education SPIKE Prime Word Blocks App.

It's not an easy program, but it's not very complex. We have to accomplish five missions with this program. So let's get down to it. I'll zoom in and let's follow the execution of the program.

Here it is. We start from base. When we start from base, we initialize the robot. Always a good practice. We always initialize the robot. Yaw angle, motors C and D - these are the motors for the attachments. We set their speed. This is like a value that we've experimented with and we are happy with this value. And we set the initial positions of the motors. So, we need the attachment right here to be lowered to be down. So, this is the initial position of the motors. Set movement motors to E+F. And this is the start of the program. We move forward, set movement speed to 100%, and we say "Gyro Follow a Line". Gyro is the old way in which we are calling the motion sensor. So, because it was called gyro sensor in the past, here it is: the Gyro Line Follow. What's this block? Where can we find this block? I'll zoom out. And it says Gyro Line Follow. Where is this block defined? Here it is. Here is the block Gyro Line Follow. And it accepts a parameter. This parameter is distance in degrees. Distance in degrees. What do we do with this block? Zoom it in to the max. Here it is. We reset the timer. It's always a good practice to reset the timer at the start of the robot, and sometimes at the start of the blocks. And we reset the yaw angle. In this way you can stop from time to time. And there is no accumulation of the errors that the motion sensor is making because the motion sensor is always making some small errors and these errors add up. We try to reset the timers, and we try to reset the yaw angle to zero every time we have the opportunity. It's a good practice. Just make sure that there are no errors that are adding up. We set the relative position of motor E to zero. And you might remember that motor E is the one responsible for driving. Motor E and F are for driving. And we repeat, we do a loop. And we repeat. What do we repeat? We measure the relative position of E and we repeat this loop until we've moved past the distance in degrees, which was 1000. So, we repeat and we wait for this condition to occur. We wait for the motor to move past 1000 degrees. And while we are waiting, we do the following: we set the movement to speed 30, plus timer multiplied by 50. So, as the timer is going up, the speed will be going up as well. As the number of seconds is increasing, the movement speed will also be increasing. If the yaw angle is more than zero, then we compensate by rotating slightly to the left, otherwise - slightly to the right. In this way, we are accelerating with the robot - this Gyro Line Follow - but in the same time, while accelerating, we are also keeping a straight line. And this is how it works. We start it right here. This is the move Gyro Line Follow. Because it's not a line that's on the field, it's a line that's forward direction. This is the Gyro Line Follow. When we reach the mission model, the Toy Factory mission model, we set movement speed and we make the robot move a little bit slower, and we set the movement speed to 20. And in this way, when we push with the attachment on the mission model, we don't risk breaking the mission model or the attachment. That's why we are slower. We move straight. And this is the move straight. And in this move straight, you can see that we precisely drop the energy units to right about here. I think right here. Here is where we stop with the 1.5 rotations. Then, we no longer have to be careful. We can set again the movement speed to 100 because we are saving time here. And, as in the previous tutorial that we discussed, we broadcast a lift. It's the same broadcast where we are broadcasting a lift, and we are executing something from the program in parallel. What do we do? While the robot is moving, we are also lifting. And in this way, we can save time. Here it is. The robot is moving forward. And while the robot is moving forward, we are lifting. We lift. Okay.

Then, when we get to this position, we start moving right, and we move right, and we wait. We wait for the yaw angle to measure something more than 50 degrees. We've already have broadcast the message "Lift". The attachment is up and we rotate. This is where we stop because this is where we've reached 50 degrees. We move forward,

and as we move forward, what we do is we lower, we lower the attachment. We say, okay, lower the attachment. And as we lower the attachment, we reduce the speed. We reduce the speed and we move back. We move back to push.

After we've pulled on the attachment, we broadcast "Lift and Wait". That's another message. So let's go and check this message. Lift and Wait. Broadcast "Lift" when I receive "Lower". Is there a "Lift and Wait"? No? Here it is. There isn't such a block. There is only "Lower". But the difference is that we execute the same broadcast and lift. But this time what we need to do is to wait on the program. We need to wait before continuing with the next block. We want to wait to broadcast the message and to wait for the completion of the other blocks. This is what we are doing with this Broadcast and Wait. And it's a standard block, it's right here in the palette. Let me find it. Broadcast and Wait. So, there is an option with this version of the software. And this might, of course, change in future versions like we've seen this from LEGO a couple of times. But in the current version we have Broadcast Lift and Wait as a block, which allows us to broadcast a message and wait for the executions of the blocks that are activated when this message is received. This allows us to select whether we want to execute the blocks in parallel or one after the other. Here we just want to broadcast and wait. We lift. We are not executing anything else. And you can see that the robot is staying at the same place. We don't want to move. Then we move and we rotate. We rotate with the robot until it reaches 72 degrees. The yaw angle detects 72 degrees, which is right about here. We stop moving. We lower the attachment. We lower the attachment and we move forward. And when we lower, you can see that we lower and we move forward at the same time. Here it is. We lower and we move forward at the same time. We get to this position. And here we broadcast a lift and we will push on this lever. Let's see.

Here it is. These are like three of the missions. We have already three of the missions. And you can see that by using the broadcast block we can activate different parts of the program and we can have these different parts of the program execute in parallel. And it gives us a chance to structure. It's a very powerful tool. We can send a message. And as we send a message, we can wait for this message to be received and for the blocks to be executed, or we can just say, hey, here is a message, go execute a couple of blocks. And we are not waiting for them to be executed. We are continuing with the program, which allows us to do things in parallel, which is power. So where were we? We were right here on Broadcast Lift and Wait. Next, we move back. Rotations 1.

Move back. And the next thing we want to do is Line Follow. A Line Follow. So, this is another block and we need to do a line follow. Where is the block for line following? Here it is. We have distance in degrees, and we have some accuracy, which is the way of us saying whether we should turn really fast if we lost the line, or whether we should turn in a more slower or smooth way to approach the line. And it really depends on the shape of the line. And we should experiment with this accuracy for each and every robot. But how would this work? This would work in the following way: we are searching for the line. Searching for the line. Searching for the line. And we catch the line. How? We set the relative position of motor E to zero. And then we do the following thing. We repeat a certain set of blocks until we've reached distance in degrees. Until the robot has moved more than the specified distance in degrees. This is how we measure the distance. And while we are waiting for this event to happen, and we are moving with the robot, we are also checking the color. And if the color is black, then we move slightly to one side. If the color is not black, we move to the other side. One side. The other side. One side. The other side. One side. The other side. One side. The other side. One side. The other side. Somewhere around here, we've moved to more than... What was it? 430 degrees, I think. 430 degrees. Yes, here it is. We are right here. We've just stopped with Line Follow for. We move. And we continue with our program, with our pattern of executing the program. We move for a couple of rotations. We rotate. We wait for the yaw angle. We measure where we are on the field. We broadcast lift, broadcast lower. Broadcast lift, broadcast lower. We wait. This is how we complete the program.

What can we take from this program? What can we learn? We can learn that, okay, we can split the program in smaller parts by using blocks. Then we can also split it in smaller parts by separating the program in different parts that could be executed in parallel. And we can send messages to the robot. And when the robot receives the message, it could execute part of its program in parallel. For example, while moving, we can also lift. We can use the yaw angle to detect where we are on the field and our at least orientation on the field. And we also use a small block for line following. How do we end the program? We end the program by returning back to base. I know it's too much. I know it's too much. But these are five missions. We want to get five missions with a single program. And, naturally, the program grows and becomes bigger. So, we really need to have a balance here. How complex of a problem we can handle and how complex of a mission run we can handle. Naturally, when the missions are more complex, the problem is more complex. But as you see, it's just repeatable patterns in the program. So, it's easy to learn these patterns and to try to implement them for your robots. I think this is like the largest number of missions that we've recorded in a single run - five, which is really cool. Which is really cool. See you in the next tutorial.

Курсове и занятия включващи този Урок

Този Урок е използван в следните курсове и занятия.

Image for FIRST LEGO League 2022-2023 Super Powered solutions and review with LEGO Education SPIKE Prime
  • 25
  • 90:56
  • 15
Image for Drop, Pull, Lever. 5 missions with Kriket box robot
  • 3
  • 0
  • 0
  • 3d_rotation 6