Using the Competition Template in VEXcode Pro V5

The VEX Visual Studio Code Extension has replaced VEXcode Pro V5, which is now end-of-life.

VEXcode Blocks and VEXcode Text remain actively developed and supported for all VEX platforms.

Opening the Competition Template in VEXcode Pro V5

VEXcode Pro V5 interface with File menu open and Open Examples option highlighted.

Click on “File” on the top left of the VEXcode Pro V5 app, then select “Open Examples…” from the dropdown menu.


Selecting the Competition Template

Examples window showing Competition Template option selected in the templates list.

From the “Examples” window, you will see two different competition “Templates.”

  1.  “Clawbot Competition Template”. This template comes with V5 Clawbot devices pre-configured.
  2.  “Competition Template”. This template doesn’t come with any device configurations.

We will be using the “Competition Template” for our example since the steps are the same for either template.

NOTE: The Competition Template is a sample project that sets up all of the necessary callbacks in order to communicate with the Field Control System during competitions, ensures code is in compliance with field regulations, and aids in setting up programs in order to avoid complications and disqualification ("competition" refers to a VRC event using the official field control hardware).  


Naming Your Project

Example Project window showing project name field filled with MyProject1, and the Create button is shown below.

Enter a project name of your choice. Then click “Create.”


NOTE: Project names must NOT contain any spaces and must be less than 20 characters long.


Understanding the Three Sections of the Competition Template.

VEXcode Pro V5 code editor showing main function with Competition.autonomous and Competition.drivercontrol callbacks and pre_auton() call.

NOTE: The competition template has three sections that correspond to the three phases of a competition match: Pre Autonomous (robot setup), Autonomous period, and Driver Controlled Period.

In order for your code to work at a competition, you must:

  1. Leave the code below inside the main function in place.
  2. Add your code inside one of the three functions (pre_auton, autonomous, usercontrol).

Using a Pre-auton Function for Any Setup Steps

VEXcode Pro V5 code editor showing pre_auton function with vexcodeInit() and setup comments for pre-competition tasks.

Add any setup steps such as gyro calibration, or other sensor resets that should run when the program is started, to the pre_auton function.

NOTE: The code inside the pre_auton function below will run immediately when the program is started, before the autonomous portion of the match begins.

NOTE: If you choose not to use this section, leave it empty.


Using the Autonomous Function for Any Autonomous Routine

VEXcode Pro V5 code editor showing autonomous function with placeholder comments for autonomous routine code.

Put the code for your autonomous routine into the autonomous function. Your autonomous function must only contain commands that won’t need any interaction from a user. (E.g., BumperA.pressing())You should avoid any commands that require a user’s interaction. E.g Controller1.ButtonA.pressing();

NOTE: You can copy and paste this code from another project file.


Using the usercontrol Function for Any User Controlled Routines that Take Place During the Driver Controlled Period

VEXcode Pro V5 code editor showing usercontrol function with while loop and wait(20, msec) for driver-controlled code.

The usercontrol function must only contain commands controlled by the user. (E.g. Controller1.Axis1.position();)Put your driver control code into the usercontrol function, inside the while(1) loop and before the wait(20, msec) command.

For more information, help, and tips, check out the many resources at VEX Professional Development Plus

Last Updated: