🏆 Competition Template

The Competition Template Explained

What the PROS competition template actually is, how the five hook functions work, when to use a competition switch, and what happens to your code at a real match.

1
The Template
2
Match Phases
3
Comp Switch
4
Match Day
5
Checklist
// Section 01
What the Competition Template Is
The competition template is not EZ Template — it is the PROS framework that controls when each part of your program runs during a real VRC match.
ℹ️
Two different things with similar names: The PROS competition template is the hook function structure (initialize, autonomous, opcontrol, etc.) that controls when code runs. The EZ Template is the drive library that lives inside it. You always use both together.

The Five Hook Functions in main.cpp

When you create a PROS project, src/main.cpp contains five special functions. PROS calls these at specific moments during a match — you do not call them yourself. The field control system triggers them.

FunctionWhen it runsWhat to put here
initialize() Once, when the Brain powers on or program starts Motor configurations, sensor setup, EZ Template chassis init, auton selector registration. Runs before anything else.
competition_init() Once, when connected to a field controller Usually empty for most teams. Can be used to reset variables or show a message when plugging into the field at a competition.
disabled() Repeatedly, during any disabled period The EZ Template auton selector runs here automatically. You can add a loop to update the Brain screen or blink an LED. Motors cannot be commanded during disabled.
autonomous() Once, at the start of the 15-second autonomous period Call ez::as::auton_selector.call_selected_auton() to run whichever routine was selected. All autonomous movement commands go in your separate auton functions.
opcontrol() Repeatedly, during the 1:45 driver control period Controller input loop: chassis.opcontrol_tank(), mechanism controls, button handling. This is the main driver control loop.
// src/main.cpp — the five functions in order void initialize() { // Runs ONCE on startup ez::as::auton_selector.autons_add({ /* your routines */ }); chassis.initialize(); } void competition_init() { // Runs ONCE when field controller connects — usually empty } void disabled() { // Runs REPEATEDLY while disabled — auton selector shows here } void autonomous() { // Runs ONCE for 15 seconds — call selected auton ez::as::auton_selector.call_selected_auton(); } void opcontrol() { // Runs REPEATEDLY for 1:45 — driver control loop while (true) { chassis.opcontrol_tank(); pros::delay(ez::msec2); } }
💡
The most important rule: never block initialize() indefinitely. If your initialize function never returns, your robot is stuck in initialize forever and neither autonomous nor opcontrol will ever run. Keep initialize fast and non-blocking.
// Section 02
What Happens During a Match
A VRC match has four phases. Understanding exactly when each function runs — and what your robot can and cannot do in each phase — prevents a whole category of match-day surprises.
🔌
Before the match — can last minutes
Disabled Period
The robot is plugged into the field. Motors cannot run. The auton selector appears on the Brain screen. This is when you pick your autonomous routine using the controller joystick. The disabled() function runs in a loop here.
➤ disabled() loop | ➤ auton selector active | ➤ motors locked
▶️
0:00 — lasts 15 seconds
Autonomous Period
The field enables autonomous. PROS calls your autonomous() function exactly once. Your selected routine runs. The driver cannot touch the controller — any button press is ignored. After 15 seconds, the field disables autonomous whether your routine finished or not.
➤ autonomous() called once | ➤ controller input ignored | ➤ 15 sec hard limit
👤
0:15 — lasts 1 minute 45 seconds
Driver Control Period
The field enables driver control. PROS calls opcontrol(). Your driver control loop starts. The driver can now use the controller. This period runs until the match ends at 2:00. If opcontrol() somehow returns early, the robot stops responding — always keep it in a while(true) loop.
➤ opcontrol() loop | ➤ controller active | ➤ 1:45 duration
2:00 — end of match
Match Ends — Disabled Again
The field cuts all power to motors. PROS enters disabled mode again. Your robot must stop immediately — any movement after the buzzer results in a rules violation. Do not write code that intentionally moves after opcontrol() is expected to end.
➤ motors cut by field | ➤ disabled() resumes | ➤ no movement allowed
// Section 03
The Competition Switch
A competition switch is a small hardware device that simulates the field control system — letting you test your full match sequence (disabled → autonomous → driver control) without an actual competition field.
💡
Always test with a competition switch before your first event. Autonomous routines that work when you run them by hand on the Brain screen do not always work correctly when triggered by field control. The switch lets you test the full match sequence in practice.

What the Competition Switch Does

The V5 Competition Switch (VEX part #276-2338 or equivalent) is a small box with two ports and a toggle switch. It connects between your robot and acts as a simplified field controller:

Port 1
Controller Tether
Connects to your V5 controller via tether cable
Port 2
Competition Switch
Toggle switches: Enabled/Disabled and Autonomous/Driver
■ Disabled — motors locked, auton selector shows
▶ Enabled + Auton — autonomous() runs
▶ Enabled + Driver — opcontrol() runs

When to Use a Competition Switch

ℹ️
Without a competition switch: you can start autonomous manually from the Brain screen (run the program directly), but this skips the disabled()autonomous() transition that happens at a real event. It also bypasses competition_init(). Always test with the switch before competing.

Testing Sequence With the Switch

  1. Upload your program to the Brain (slot 1).
  2. Connect the competition switch: controller tether into the switch, switch plugged into the controller port on the Brain.
  3. Set switch to Disabled. The auton selector should appear on the Brain screen.
  4. Use the controller to select your autonomous routine. Confirm the correct one is highlighted.
  5. Set switch to Enabled + Autonomous. Your autonomous routine runs immediately.
  6. After 15 seconds (or when routine finishes), flip to Disabled, then Enabled + Driver. Driver control should start.
  7. Flip back to Disabled at the end. The robot should stop responding immediately.
// Section 04
What Happens at an Actual Competition
At a real event, your robot is controlled by the official field management system (FMS) — not your competition switch. Here is the exact sequence so there are no surprises.

The Field Management System (FMS)

At a competition, the tournament staff runs field management software that controls all robots simultaneously from a central computer. When the referee enables autonomous or driver control, the FMS sends a signal through a cable in the field perimeter to your robot's controller. Your code responds exactly as it did with the competition switch — because it is the same signal protocol.

ℹ️
Your code does not change for competition. The same program you tested with the competition switch runs at the event. The FMS replaces the switch — you do not need to modify anything. This is why testing with the switch is so important.

The Sequence at Each Match

  1. Queue for your match. Staff will call your team to the field about 5 minutes before your match. Bring your robot and any tools.
  2. Connect to the field. A tether cable from the field connects to your controller. Your robot enters disabled() and the auton selector appears.
  3. Select your autonomous. Use the controller joystick to scroll to your planned routine. Confirm it is highlighted. Double-check your robot's starting position on the field tiles.
  4. Autonomous period starts. The referee signals and the FMS enables autonomous simultaneously for all robots. Your autonomous() function runs.
  5. Short disabled period. After 15 seconds of autonomous, all robots are disabled briefly while the field transitions.
  6. Driver control starts. The FMS enables driver control. Your opcontrol() loop begins. The driver has 1:45.
  7. Match ends. The buzzer sounds, the FMS cuts all motors. Your robot must stop. Do not touch the robot until instructed by the referee.
⚠️
Do not touch your robot during a match — including trying to push a button, adjust something, or pull the USB cable. Any physical interference during a match is a rules violation that can result in disqualification.

Common First-Competition Code Surprises

// Section 05
Match Day Checklist
Complete this checklist for every match. Your progress saves automatically in your browser.

Night Before the Event

Morning of the Event

Before Each Match

All checked for this match? You are ready. Visit the Brain Download guide to review the upload process, or return to the main resource hub.
⚙ STEM Highlight Technology: Event-Driven Programming & State Machines
The PROS competition template uses event-driven programming — functions are called in response to external events (field enable, field disable), not by your code. This is the same pattern used in GUIs, web servers, and embedded systems. The transition from disabled()autonomous()opcontrol() is a state machine with three states. The field controller is the external event source — your robot is the reactive system.
🎤 Interview line: “The competition template implements event-driven programming. Our code registers callback functions — autonomous(), opcontrol() — that the PROS scheduler calls when the field sends the corresponding signal. This is the same pattern as a web server responding to HTTP requests or a GUI responding to button clicks.”
🔬 Check for Understanding
Your autonomous() function works when you run it manually on the Brain, but does nothing at a competition. The most likely cause is:
The code was compiled with errors
autonomous() was not declared in the right file
ez::as::auton_selector.call_selected_auton() is missing from autonomous(), so the function runs but executes nothing
The field control cable bypasses autonomous entirely
Related Guides
🔨 Tournament Pit Crew System → 🚫 Robot Inspection Guide → 🎮 Partner Controller →
← ALL GUIDES