Skip to main content
Skip to Main Content
Skip to main content
Navigation

Chapter 4: Preparing to Compete


Lesson 2: Using the Blocks Competition Template

Hello and welcome to the VEX Classroom. My name is Lauren, and in this lesson, we are going to be going over using the Blocks Competition Template. In the previous lesson, we talked about the Competition Template a little more generally and why you need to use it during a VEX Robotics Competition match. There are different versions of the Competition Template depending on which programming language you're using, whether blocks or text. In this specific video, because in this course we're focusing on blocks, I'm going to be going over the Blocks Competition Template in VEXcode V5.

Now, before we dive into everything, let's first talk about the materials. I am going to be using the Advanced TrainingBot here just so that I can show off some of the functionality of the Arm and Claw. I also will be using a controller, a game object piece, and VEXcode V5 to actually show you this Competition Template. You do not need any materials at all for this video. I'm just going to be doing some demonstrations for you. So again, you don't need anything at all for this particular lesson.

Let's talk about the purpose of this lesson. We're going to go over the different parts of the Blocks Competition Template, more specifically, three parts: the When started, which is our pre-Autonomous, the Autonomous portion, and the Driver Control portion. I'm going to talk about those in the example code that I have here, and then we're going to actually test it and see the functionality on our robot using our controller to see what the Competition Template looks like in action.

That being said, let's go ahead and dive into our project example.

[Music Cue]

Alright, to view the Competition Template, I'm going to go up to File, Open Examples, Templates, and then Competition Template. A couple of things here. Number one, again, these three sections. One thing that I want to note before we dive into these with my particular example here is the first thing that we actually need to do before we can start populating these is add our device configuration here. So again, if you're using a 2-motor Drivetrain or you have arm or claw motors or anything like that, you first need to make sure that you add those in order for the blocks to populate on the left side there. That will allow you to again populate these sections.

As soon as I open the Competition Template, I need to make sure that I add my device configuration. Next, the one thing that I want to mention is in this Driver Control portion, you can see that the forever block is in there. The reason that that's in there is because most of the time for the Driver Control portion, when we're using the controller, we want to be continuously checking if buttons are pressed or joysticks are moved. So that's why the forever block is in there by default. If you wanted to remove it for any particular reason, you could, or if you're not using that stack and you're just using the device configuration, then you can just leave that as is.

Alright. Let's take a look at each of these three sections and what they actually mean with an example that I made.

[Music Cue]

To start off, I want to note there are three main portions of our Competition Template. The first is the When started or the pre-autonomous. The second is the When autonomous or the autonomous portion, and the third is the When Driver Control or the Driver Control portion. All three of these event or hat blocks execute different portions of, again, this Competition Template.

Let's talk about each section. The pre-autonomous portion or the When started is going to execute as soon as the Competition Template project is run. This is best used for setting any initialization.

Thank you for joining me in this lesson. I hope you found it helpful and informative. If you have any questions, feel free to reach out. Happy coding and good luck with your VEX Robotics projects!

So if I need to print something on the brain screen before my autonomous portion starts, if I need to calibrate a gyro, if I want to print data in this specific example, since I'm using the arm and claw, I'm going to set their motors to hold. This means that if I raise my arm up or open my claw, the motors are going to stay at that specific position and won't lower down by gravity, for example. So I'm just kind of setting these pre-autonomous notions for my motors. In this specific example, we'll take a look at what that looks like when we view the demonstration.

Music Cue

So now that I have that, that's the "When started" our pre-Autonomous portion. Next is our autonomous portion. The autonomous portion of the match is going to be 15 seconds long, and this specific section of code will run for the autonomous portion of the match. As soon as the competition template is run, that pre-Autonomous "When started" portion is going to begin no matter what. Then the 15-second autonomous is going to run. We talked about the field control system and how that's going to regulate when all robots start and stop when this specific portion is going to run in the match, this line of code is going to run.

Now, for my specific example that I have here, our robot is going to start with a game object in the claw. It's then going to close around the object, raise up in the air, drive forward for 200 millimeters, lower the arm down, and drop our game object down. This could simulate scoring a piece in the beginning of the match, for example. So that's what's going to happen during my autonomous portion. Again, the autonomous portion means that I can have no driver control with the controller effect on my robot. During this portion, everything is autonomous. Everything is done via code.

Taking a look at this third portion over here, I have my Driver Control. Now, one thing that I want to point out is that in our device configuration, I can obviously have my drivetrain configured and a controller configured, which means that I can assign different drivetrain configurations to my joysticks and I can also assign different buttons to control different motors. However, let's say that I've run out of buttons on my controller or I have different things that I want to manipulate. I can add to this "When Driver Control" event block certain things that I want to do that maybe I don't have access to in the device configuration, or maybe I want to set the speed of my drivetrain, or things like that.

So my specific code example here again, for the Driver Control portion, this is going to allow me to control my Claw with one button on my controller. We're going to see what that looks like. So again, when I'm using the Driver Control portion, I can use both the device configuration with the controller and the driver control portion at the same time. Or I can use one or the other. If you are not using any of these three stacks, the pre-autonomous "when started," the autonomous, or the driver control, you can leave them blank.

Music Cue

All right. Now that all that is said, let's actually take a look at what this looks like when I'm actually going to run it on my robot. All right. Let's take a look at this on my controller, actually. I can navigate over to programs and I can see my Competition Template project there that I already downloaded on my brain. And if I scroll over one, there's an option there for the timed run. This is going to simulate the field control system that I talked about earlier, how everything is controlled by that field control system. So when the competition project actually starts is controlled by that, when the autonomous portion of the match is controlled by that, and when the Driver Control portion is controlled by that, I can simulate that using this timed run on the controller.

Thank You Note

Thank you for taking the time to explore this process with me. I hope this demonstration has been helpful.

Final Message

Feel free to reach out if you have any questions or need further clarification. Happy coding and good luck with your robotics projects!

So if I select that and it's going to tell me here 15 seconds for the autonomous portion, one minute, 45 seconds for the Driver Control. And when I push this button again, it's going to actually start. When I start it, it's going to count down 3-2-1, just like you would in a match. And then we're going to get started.

So as soon as I click start, the autonomous portion is going to run, or the pre-autonomous is going to start first no matter what. Then it's going to immediately start that autonomous portion. So I will show you as soon as it starts doing the autonomous portion. Even if I move my controller for the robot to move, it won't move because again, during the autonomous portion, I cannot control my robot using the controller.

[Music Cue]

So let's actually see that specific part happen. All right, here we go. All right. Now, I still have a couple seconds left in the autonomous portion. You can see even when I'm moving my controller, nothing is happening because I cannot control my robot using the controller during the autonomous portion. But as soon as it flips to the driver control, now I can actually control my robot.

So I'm going to go forward here because remember coming over to the project for our Driver Control portion, I can control these different parts. So I have one minute and 25 seconds left. I am going to drive up now based off of the driver configuration there, this controls the drivetrain, this controls the arm, this button controls the Claw. One button press is going to allow me to grab objects. I can raise two buttons here to raise and lower the arm. One button to control the Claw. Closed, Open.

Now, this is not an option in the device configuration, so I had to custom make that code, which is exactly why I used the Driver Control event block there that you can see in that particular stack. It's going to continue to count down for the rest of my Driver Control portion. But as you can see there, I'm going to stop that. Once the Driver Control portion has ended, everything shuts down and that's it for the match.

You can see the three different parts of the template. Once again, we go through the when started section of the pre-autonomous is going to run regardless, no matter what section of it, If we're doing autonomous or Driver Control, we then get into the autonomous portion. I cannot use my controller when this is happening. Once that is up, it's going to move into the Driver Control portion where I can actually control my robot using the controller and that's going to run for one minute and 45 seconds until it is over. Then, as I mentioned before, using the field control system, all robots will start and stop at the same time.

[Music Cue]

All right. Let's just do a quick recap on what we covered in this video. We looked at the Blocks Competition Template. There are three different portions. The When started, pre-autonomous, which is going to run regardless. This is for initializing variables, maybe setting up and calibrating a gyro, printing thanks to the brain screen, setting motor positions such as hold or maybe even raising the arm to a particular position. This is all done before the autonomous portion of the match.

Then we get into the autonomous portion, the autonomous stack that we saw there, that's where for 15 seconds the robot moves completely by code, no interactions with the controller or the driver. Once that section is done, we then move into the Driver Control portion, which can be controlled either via the device configuration that we saw before assigning certain motors and things to the joystick buttons and things like that on the controller and also that specific stack where I can do a little bit more custom code for my robot. You can use one or the other or both.

And as I mentioned before, if you're not using any of those three sections throughout your program, you can leave the stacks in the event blocks blank as well.

Thank you for watching and I hope this helps you understand the competition template better.

Again, the reason for using this template is to ensure during a match all of the robots start and stop at the same time. That's because there are going to be four robots on the field, and we want to ensure, again, all the robots start and stop at the same time.

I hope that all of this information was helpful as you learn about the Competition Template and really get ready to compete in a VEX Robotics Competition match. I am so excited.

Congratulations, you finished Chapter Four, and I will see you in another video.

Learning Objectives

Learning Objectives Section
  • Define the main elements of the Blocks Competition Template in VEXcode V5, including the when started, autonomous, and driver control sections.

Summary

Summary Section

This is the second video of the Introduction to VEX V5 Training Course Chapter 4. If you have not yet watched the first video, go back and watch Lesson 1: Mechanics of a VEX Robotics Competition Match.

In Lesson 2, you will learn about each of the three main elements of the Blocks Competition Template in VEXcode V5 by viewing an example in action.

For discussions and questions, join our dedicated PD+ Community thread for collective learning and exploration.

Congratulations, you have completed the Introduction to VEX V5 Training Course!