In this video tutorial, we accomplish three missions in a raw. It is a little longer and more detailed tutorial, but hey, 3 missions, one after the other. These are the Wind Turbine, where we have to push 3-4 times and collect the energy units, the Watch Television, where we reach the mission model and slightly push, and, of course, the Rechargeable battery - where we collect the energy units.
- 20 Oct 2023
- LEGO Education SPIKE Prime
- Push, Collect, Multiple missions, FIRST LEGO League, FIRST LEGO League 2022-2023 Super Powered, Box Robots, Attachments, Gears, LEGO Education SPIKE App Word Blocks, Scratch
The tutorial has several parts, each looking at a different mission, one after the other.
Full run of the three missions from going out of base to completing each of them.
In this video tutorial, we accomplish the FIRST LEGO League 2022/2023 SUPERPOWERED missions with our Chain Monster robot and this nice frame with an attachment. We are accomplishing three missions in this video, where we have the first mission, the Watch Television, the second mission is the Wind Turbine, and the third mission is the Rechargeable Battery. All three we accomplish at once. First, let's look at our robot and the frame with the attachment that we use. This is the Chain Monster, and we have this pinless attachment for it. On the Chain Monster, we have two places where we can attach an attachment on top of the robot. Below the robot, we can see the motors that are powering these attachments. We place the frame with the attachment and we glide it on the robot. It's a pinless attachment, so it's quite fast. We just glide the attachment and place it on the robot. The next thing is we start from base. This robot starts from base and it will accomplish three missions. The first mission is the Rechargeable Battery. We must collect this battery and we must return it to base. That's the goal of the mission here. The second one is the Watch Television, where we must push. But, when we push, we must push with enough force to get the television up but not too hard, so that we don't push the batteries out of the place. And the third is the Wind Turbine. Here, we must push a couple of times and different batteries will fall and we must collect them, and bring them back to base. First, we align the robot, and we will record a separate part of this tutorial of how we align the robot. When we align the robot in the base, we add the attachment. We glide the attachment on the top of this box robot, the Chain Monster. It's a pinless attachment. We start, we push the television model, we go for the battery, and then we go for the wind turbine. We push on the wind turbine three, four times to make sure that all the batteries fall, and that's it. Let's look into more details. The first detail of this robot and how we execute and accomplish the missions is how we align the robot in the base. We align the robot to the wall and to the right black line, the thin one. That is how we start the robot, and it's always good to start aligned. Then, we make sure that the chain is okay. Now, we are ready to start the robot. We'll start the robot with the Play Button, the one that's on the right. We place the frame with the attachment. It's pinless, and it's quite fast. You see? We just put the frame right here.
It's important to look from another angle so that you can see how the robot behaves and how the robot accomplishes the missions. That's why we've rotated the camera and we wanted to show you the robot run, but from a different angle. Again, the television is first, return to base, then we go for the rechargeable battery, and then we go for the wind turbine.
Three, and one more just in case. Now, you can remove this or you can leave it when you accomplish the mission. It's up to you. One of the things that I like to do when we focus on a multi-mission run is to look at the different missions. We have this battery here that's initially below the TV, and the goal is to push with the robot, but with just enough force to get the battery right there on the green part. But if the push is too hard, the battery will move away and we won't be getting the points that we want to get. So, we get maximum points if we push it, but just with enough force to get the battery on the green parts. And this is a common occurring mission on FIRST LEGO League competitions where you just have to push, but not very hard.
The next mission is the Rechargeable Battery, and we just have to collect it. It's a small object, and we have to move, collect it, and return to base. The third closeup that we do here in this tutorial is for the Wind Turbine mission, where we have to move and push on the mission model. We can do it three times, but we do it four times just to be sure. We collect all the energy batteries with the robot. Let's go into the programming.
This here is the program, along with the recording of the video. You can see that the program is not very simple, but it's also not that big. These are three missions, and we accomplish all of them, three of them, in a single run. Let's look at the program. First, if I zoom in, we have a 'when a program starts', we set motor rotation to 17.5 centimeters, move. Movement speed to 50%, set movement to motors A and B, and these are where the cables for the motors are connected, and set movement motors to brake at stop. We are experimenting with with brake at stop. Let's see the behavior of brake at stop. And it seems to be working. It seems to be working pretty well for now. Then, motor C. Set motor C, which is the one that's controlling the attachment. Set motor C to brake at stop and go the shortest path to position zero. We just want to make sure that the motor is aligned. What aligned means is that it will not start from an angle that's not correct. It's aligned. Sometimes, when the motor starts from an angle, let's say, minus three or three or five or minus five, we get an inconsistent behavior. So, this here, resetting the motor to initial position, is really important. Then, we initialized a few variables, and we'll see below how we use these variables. And the variable that we need is angle orientation set to zero. And let's stop here for now with what angle rotation is. We will see how we use it. It's just a variable that we need to use. And then we set the yaw angle to zero because we plan to be using the motion sensor. What happens next? Next is a block where we wait until a button is pressed. Why do we need to wait until a button is pressed? Sometimes, we want to split the program in a number of different smaller programs. And what we need to do here in the program is to be able to switch, to wait, to start one program, then wait, start another program. And this is a common pattern in which you wait until button left is pressed on the brick, or button right is pressed on the brick. We just wait. And when this happens, we start moving forward. We've aligned the robot, we're waiting, we press, and it moves forward. Then, we have these blocks that are move at angle. These are blocks that we've created. These blocks are blocks that we've created in the My Block section. Go experiment, create your own blocks. You can create different blocks with different parameters. Our block is called 'move at angle'. So, zero for length, 36 in centimeters, and speed of 50%. This is how we want to move with our robot. We move forward for 36 centimeters, then for five, then for 30. Let's check it out.
This is the behavior of the blocks move at angle. Here, we have the first move at angle, that just moves forward. Then, before we reach the mission model, we need to reduce the speed so that we don't push too hard on the mission model. So, we reduce the speed from 50 to 20, and it happens right here. Then we push.
We get the television up, and then we return. How do we return? We return by setting a speed of minus 50. This is how we return. Next, let's see move at angle. What do we do with this 'move at angle'? What's the idea of this block? Because we'll be using this block a lot in this program. We want to move at an angle of a positive, zero, or negative value for a certain amount of length at a certain speed. And this is the block. And we've implemented some nice corrections in this block and nice ways in which we handle all the errors, not all, not all, some of the errors that could occur while we are using this block. This block is not simple. This block is going slightly into the advanced section because it does a lot. We want to move with the robot for a specific length at a specific speed and to keep our rotation at а specific angle. What we are naturally doing there is the following: we detect the rotation of the motors with the motor B. We can use motor A, but we've decided to use motor B. So, set relative position of motor B to zero. This is where we start measuring the distance. But how do we measure the distance if we don't know the diameter of the wheels? And, this is what we are doing here. We are setting a variable, and I see here that there is a typo here, but doesn't matter. We set a diameter of the wheels to 5.57, and then we make a calculation. What's the number of angles, number of degrees that we must rotate with the motor to get us to this distance? And this here is the calculation. So, we need the length divided by the diameter of the wheels, multiplied by 360 divided by Pi, and that's the number Pi. So, for 5.57 and with the diameter and we have the length, we know the number of degrees that we must rotate. And we say, okay, we calculate the number of degrees. And, once we calculate the number of degrees, what we need to do is to set this number of degrees that we've calculated to a variable. Angle to rotate. What's the angle to which we must set the motors to rotate in order to get this length? So, take a look at this; download the program. Try to get the basic math equation. And what we need to find is the circumference of the circle. And we need to repeat this circumference a number of times to get to the length. So, this here is the circumference of the circle, and we divide the length by the circumference. And in this way, we know the number of degrees we must rotate, i.e. the number of rotations that we must make. Then, what we want to do is the following: we want to set the block repeat until we reach this number of degrees with motor B. So, we move forward until the angle to rotate is equal to the absolute value of motor B. Or it is less than the relative position of motor B. And the reason why we do this is we repeat until this is true. So, it is possible that we need to rotate to, let's say, 400 degrees. And when we rotate to 400 degrees, it is possible that motor B will detect 390, 391, 395, 398, 401. If we just have the equals to section, we will never detect that the motor has rotated to 400 degrees. That is why we need the angle of rotation to be less than the relative position of motor B. So, if the motor has rotated to exactly 400 degrees or more, then we stop. But until then, we repeat. And what do we repeat? This was the move forward. And now we want to keep direction with the robot. We set the current angle to the yaw angle that we are currently facing, and we know the angle that we want to rotate. In our case, for this particular run, it is zero. So, angle minus zero. So, zero minus zero equals zero, multiplied by the correction strength zero and speed plus zero, which means that the left motor is moving with speed and the right motor is moving again with speed. It's a nice little trick of how we do proportional line following and proportional move forward. It's proportional. Look what happens if the angle that we want to rotate is slightly different. It's, let's say, five. We want to rotate five degrees. We say, okay, what's the angle that we want to rotate? Five minus the current angle. Current angle is zero. So five minus zero is five. Multiplied by one is five. Speed of 50 plus 5 is 55. So, one of the motors will be moving with power of 55 and the other will be moving with power of 45. And we've looked at this algorithm many different times at FLLCasts and we've discussed it. And it's a very common algorithm for keeping a straight line. And in our case, we are using it for moving either to the left or to the right. And this is a configuration with the parameter of the block right here. So we can say to this block, move forward for 30 degrees and rotate to an angle of 10. And this is what this really smart block here will do for us. In the end, a great trick, something that just blows our minds. We want to build consistent and reliable robots, and we want the robots to stop exactly where we need them to stop. We found out that if we set move backwards for zero degrees, it will automatically stop, which is so cool, really nice. This is how our block behaves. This is the block. Now let's return to the program again. The program continues in the following way: We move, we move, we move, we return to base. On the third move, we return to base. Then we rotate. Here is the part where we rotate. You saw how we got the attachment up. We need to open our container for us to be able to take this small rechargeable battery right here. This is the part where we rotate with motor C. Cool. And then the interesting thing: you see there is no rotation here with the motors. There's none. We have everything in our block. And we say: Robot, now move to this angle. That's the direction we want to go in. Go this direction, -47 degrees, measured with the motion sensor for a length of 60 centimeters at the speed of 50. And, this is how the robot works on this. It goes and it stops right here. Right here. You see, there is some inertia, but as we set the block so that the robot stop by moving backwards for zero degrees, it stops like this. This inertia will be something we'll be dealing with in a lot of the tutorials. But here it just stops and it's useful for us. Then, we close our container right here. We want to return to position zero and we return to position zero like this.
And, if you look at the attachment, you'll see that the attachment is connected with one of the motors, motor C, and we can control it from the motor C. Then, we need to return a little bit. We continue in this direction, minus 47 for a length of 10 centimeters. And then we say, okay, we're right here. Then we say, now from this direction, move at an angle of minus 30 for a length of 10 centimeters at a speed of 50.
Which is right here. We want to move in this direction with this speed. And then move at an angle of 45 for a length of 18.
And we get to here.
We get right here.
Then, we start repeating. We need to repeat the cycle four times. We move at an angle of 45 for a length of 20. Now, you might think, where do these numbers come from? They come from experiments. We don't know them. We don't calculate them. We don't make a mathematical model of this. We just experiment with the different numbers, and we know the angle that we need to move to and the speed and how far. So, this is for 20 centimeters. So, we repeat that. We go forward like this. We wait for one second for the energy unit to drop from the mission model, the wind turbine. And then, this is one second, we move back. How do we know that we move back? We move back because here we have minus 50. And then we repeat.
After the fourth time, we start motor A. We just start motor A right here. And now we can use the move angle again. We've decided to go with the start motor so that you can see that you can combine the different principles from different parts in a single program. So, we move with motor A, and we wait until the yaw angle is equal or more than 120 degrees, which is our block for rotating. We wait until the yaw angle is 120 or more, which happens right here, somewhere right here. And then, we move at an angle of 160 for a length of 50 at the speed of 80, i.e. 'return the robot back to base'. That's it. And we even return the robot before the wind turbine stops. You can see the wind turbine right here. The wind turbine is still rotating, and we've managed to return the robot. That's it. This has been a long run and a huge tutorial and I know that it's huge. I'm sorry about this. It's the first tutorial from this course, and we really need to explain a lot of things about the program and how the program works. As you know, we are trying to keep the tutorials at about 5 to 10 minutes, but this one is longer because it has three missions after all. We are trying to explain and to demonstrate how we build robots that can accomplish many missions in a single run. What you should take from this tutorial, before we move on to the next one, is the program. In the program, we have this principle here for waiting until a button on the robot is pressed, which is useful when we want to control the robot while it is still working and we have a way to split different programs. We can start part of the program and then wait until a button is pressed, which gives us enough time to align the robot in the base. This is the principle in which you have only one program and you don't lose time changing the programs at the competition, which is an important principle. We have this move at angle, which is a really compact block, which allows us to use any number of robots and sizes of wheels to move at a certain angle, at a certain speed for a certain length.
It's a compact model. It's a very involved block. It has a nice mathematical calculation for the length that we should go. Using the length, we calculate the amount of degrees that we should rotate. We also have this block here for correcting the angle. So, how do we turn to an angle? One of the motors moves with a little more speed than the other. And in this way, by regulating the speed with which the two motors move, we managed to turn to a specific angle. And, we also demonstrated that we can use the move at angle. And, at the same time, we can also use the normal blocks from the SPIKE, which are 'wait until', 'compare yaw angle', just 'turn' while staying at the same place without using the 'move at' block. That's it. Hope this is useful. Hope this gives you a good perspective of how you can accomplish these missions consistently and reliably. I'll see you in the next tutorial which is the 10 out of 10 for these three missions. Let's go for the 10 out of 10.
Courses and lessons with this Tutorial
This Tutorial is used in the following courses and lessons