Difference between revisions of "VEX2 Competition"

From ROBOTC API Guide
Jump to: navigation, search
 
(32 intermediate revisions by one user not shown)
Line 1: Line 1:
 +
<yambe:breadcrumb self="Competition Overview">VEX2|CORTEX</yambe:breadcrumb>
 +
<br />
  
{| style="font-family:Verdana, Genega, sans-sarif; font-size:80%;color:gray;" width="100%" cellpadding="0%" cellspacing="0" border="0"
+
{|
 
|-
 
|-
|  
+
|There are three possible configurations that can be used to test your ROBOTC program for a VEX Competition.
''[[Main_Page|Main]] >> [[VEX2_Main|CORTEX]] >> [[VEX2:_Competition|Competitions with ROBOTC]] ''
+
 
 +
#Using legacy 75 MHz crystals for wireless communications between transmitters and robot.
 +
#Using the new VEXNET for wireless communications. And the manual switch competition emulator
 +
#Using the new VEXNET for wireless communication. And the ROBOTC IDE connected via orange cable for competition testing.
 +
 
 +
Each of these is discussed in the next set of pages.
 +
 
 +
There are three states that need to be handled in a user’s competition program. These are:<br />
 +
 
 +
{| class="parameterTable" cellpadding="5%"
 +
  ! style="color:white; background-color:#c0504d; border-color:#000; border-style: solid; border-width: 2px 0px 1px 0px"|State
 +
  ! style="color:white; background-color:#c0504d; border-color:#000; border-style: solid; border-width: 2px 0px 1px 0px"|Explanation
 +
  |-
 +
  | style="color:white; background-color:#c0504d; border-color:#000; border-style: solid; border-width: 1px 0px 0px 0px"|DISABLED
 +
  | style="color:black; background-color:#d8d8d8; border-color:#000; border-style: solid; border-width: 1px 0px 0px 0px"|The robot is DISABLED. This condition can occur befor the start of either the Autonomous or User Control session. All motors and servos are disabled.
 +
  |-
 +
  | style="color:white; background-color:#c0504d; border-color:#000; border-style: solid; border-width: 0px 0px 0px 0px"|AUTONOMOUS
 +
  | style="color:black; background-color:#f4f4f4; border-color:#000; border-style: solid; border-width: 0px 0px 0px 0px"|A timed (20 second) duration period. Input from the joysticks is blocked. User program can control motors.
 +
  |-
 +
  | style="color:white; background-color:#c0504d; border-color:#000; border-style: solid; border-width: 0px 0px 2px 0px"|User Control
 +
  | style="color:black; background-color:#d8d8d8; border-color:#000; border-style: solid; border-width: 0px 0px 2px 0px"|Input from the joysticks is available. User program can control motors and servos.
 +
  |-
 +
  |}
 
|-
 
|-
 
|}
 
|}
 +
<br />
  
 +
{{tl|1|}}
 +
<br />
  
{| class="wikiText"
+
== Competition Template ==
 +
{| style="font-family:Verdana, Geneva, sans-serif; color:black; background-color:#FFFFFF; text-align:left; font-size:100%;" width="100%" cellpadding="5%" cellspacing="0" border="0"
 
|-
 
|-
|In normal ROBOTC programming, every program is based around a “task main” function, as shown below:<br />
+
|
 +
In normal ROBOTC programming, every program is based around a “task main” function, as shown below:<br />
  
<syntaxhighlight lang="ROBOTC">
+
{| style="font-family:Verdana, Geneva, sans-serif; color:black; background-color:#FFFFFF; text-align:left; font-size:100%;"  cellpadding="5%" cellspacing="0" border="0"
 +
  |-
 +
  |<syntaxhighlight lang="ROBOTC">
 
task main()
 
task main()
 
{
 
{
  
 
}
 
}
</syntaxhighlight><br />
+
</syntaxhighlight>
 +
  |-
 +
  |}
 +
<br />
  
 
In a competition program, things are a little different. To keep things simple, however, a Competition Template program is built into ROBOTC for use in VEX Competitions. The template provides a common starting point for teams when competing in an event. Rather than a single “main” task, the template has three sections, each matched to a specific section of the competition:<br />
 
In a competition program, things are a little different. To keep things simple, however, a Competition Template program is built into ROBOTC for use in VEX Competitions. The template provides a common starting point for teams when competing in an event. Rather than a single “main” task, the template has three sections, each matched to a specific section of the competition:<br />
Line 28: Line 62:
 
|-
 
|-
 
|}
 
|}
 +
<br />
  
 
+
=== Open a Competition Template ===
{|
+
|-
+
|style="vertical-align:top"| __TOC__
+
|-
+
|}
+
 
+
 
+
== Open a Competition Template ==
+
 
{| style="font-family:Verdana, Geneva, sans-serif; color:black; background-color:#FFFFFF; text-align:left; font-size:100%;" width="100%" cellpadding="5%" cellspacing="0" border="0"
 
{| style="font-family:Verdana, Geneva, sans-serif; color:black; background-color:#FFFFFF; text-align:left; font-size:100%;" width="100%" cellpadding="5%" cellspacing="0" border="0"
 
|-
 
|-
 
|To open a competition template:<br />
 
|To open a competition template:<br />
 +
Go to File, select "New" and select "Competition Template"<br />
 
[[File:open_comp_1.png]]<br />
 
[[File:open_comp_1.png]]<br />
 
''Note:'' The competition template is a read-only file, so be sure to save a copy of the file somewhere else on your computer.
 
''Note:'' The competition template is a read-only file, so be sure to save a copy of the file somewhere else on your computer.
Line 47: Line 75:
 
<br />
 
<br />
  
== Set Up Competition Control and Timing ==
+
=== Set Up Competition Control and Timing ===
 
{| style="font-family:Verdana, Geneva, sans-serif; color:black; background-color:#FFFFFF; text-align:left; font-size:100%;" width="100%" cellpadding="5%" cellspacing="0" border="0"
 
{| style="font-family:Verdana, Geneva, sans-serif; color:black; background-color:#FFFFFF; text-align:left; font-size:100%;" width="100%" cellpadding="5%" cellspacing="0" border="0"
 
|-
 
|-
|{| style="font-family:Verdana, Geneva, sans-serif; color:black; background-color:#FFFFFF; text-align:left; font-size:100%;" width="33%" cellpadding="5%" cellspacing="0" border="0"
+
|
 +
{| style="font-family:Verdana, Geneva, sans-serif; color:black; background-color:#FFFFFF; text-align:left; font-size:100%;" cellpadding="5%" cellspacing="0" border="0"
 
   |-
 
   |-
 
   |<syntaxhighlight lang="ROBOTC">
 
   |<syntaxhighlight lang="ROBOTC">
#pragma competitionControl(Competition )
+
#pragma competitionControl(Competition)
#pragma autonomousDuration(20 )
+
#pragma autonomousDuration(20)
 
#pragma userControlDuration(120)
 
#pragma userControlDuration(120)
</syntaxhighlight><br />
+
</syntaxhighlight>
 +
  |-
 +
  |}
 +
<br />
  
 
With ROBOTC, the competition control is completely user defined and controlled via software, so there are no jumpers required for testing. By changing these settings, the template can be adapted to work with any competition. The three lines above set the VEX controller into the “competition” mode and specify the timing for the match.<br />
 
With ROBOTC, the competition control is completely user defined and controlled via software, so there are no jumpers required for testing. By changing these settings, the template can be adapted to work with any competition. The three lines above set the VEX controller into the “competition” mode and specify the timing for the match.<br />
  
<span class="keywordBI">#pragma </span><span class="keywordI">competitionControl(competition_mode)</span> – Controls the Competition mode that the Vex robot will function in. There are two different competition modes that you can pass to this statement:<br />
+
<span class="keywordBI">#pragma </span><span class="keywordI">competitionControl</span><span class="codePunc">(</span><span class="keywordI">competition_mode</span><span class="codePunc">)</span> – Controls the Competition mode that the Vex robot will function in. There are two different competition modes that you can pass to this statement:<br />
  
*OFF – Standard setting. No competition controls.
+
*<span class="keywordI">OFF</span> – Standard setting. No competition controls.
*Competition – Competition mode. The VEX will respond to Field Controller commands and switch between Autonomous and User Control modes at the competition-specified times. Use this mode for competitions.
+
*<span class="keywordI">Competition</span> – Competition mode. The VEX will respond to Field Controller commands and switch between Autonomous and User Control modes at the competition-specified times. Use this mode for competitions.
  
#pragma autonomousDuration(time_in_seconds) - Defines the duration of the autonomous phase of a VEX competition. Poor performance may result if this setting does not match the Field Controller settings.<br />
+
<span class="keywordBI">#pragma </span><span class="keywordI">autonomousDuration</span><span class="codePunc">(</span><span class="keywordI">time_in_seconds</span><span class="codePunc">)</span> - Defines the duration of the autonomous phase of a VEX competition. Poor performance may result if this setting does not match the Field Controller settings.<br />
  
#pragma userControlDuration(time_in_seconds) - Defines the duration of the user control phase of a VEX competition. Poor performance may result if this setting does not match the Field Controller settings.<br />
+
<span class="keywordBI">#pragma </span><span class="keywordI">userControlDuration</span><span class="codePunc">(</span><span class="keywordI">time_in_seconds</span><span class="codePunc">)</span> - Defines the duration of the user control phase of a VEX competition. Poor performance may result if this setting does not match the Field Controller settings.<br />
  
  
 +
 
 +
|-
 +
|}
 +
<br />
 +
 +
=== Program and Test Competition Code ===
 +
{| style="font-family:Verdana, Geneva, sans-serif; color:black; background-color:#FFFFFF; text-align:left; font-size:100%;" width="100%" cellpadding="5%" cellspacing="0" border="0"
 +
|-
 +
|
 +
==== Phase 1: Pre-Competition ====
 +
{| style="font-family:Verdana, Geneva, sans-serif; color:black; background-color:#FFFFFF; text-align:left; font-size:100%;" cellpadding="5%" cellspacing="0" border="0"
 +
  |-
 +
  |<syntaxhighlight lang="ROBOTC">
 +
void pre_auton()
 +
{
 +
  // All activities that occur before the competition starts
 +
  // Example: clearing encoders, setting servo positions, ...
 +
}
 +
</syntaxhighlight>
 
   |-
 
   |-
 
   |}
 
   |}
 +
<br />
 +
 +
Place your initialization code inside this function.<br />
 +
During the pre-competition section, code can be executed to configure your robot before the competition begins. Valid code for this section includes tasks such as configuring sensors, setting up reflected motors and setting initial servo positions.<br />
 +
 +
==== Phase 2: Autonomous ====
 +
{| style="font-family:Verdana, Geneva, sans-serif; color:black; background-color:#FFFFFF; text-align:left; font-size:100%;" cellpadding="5%" cellspacing="0" border="0"
 +
  |-
 +
  |<syntaxhighlight lang="ROBOTC">
 +
task autonomous()
 +
{
 +
  // .....................................................................................
 +
  // Insert user code here.
 +
  // .....................................................................................
 +
 
 +
  AutonomousCodePlaceholderForTesting();  // Remove this function call once you have "real" code.
 +
}
 +
</syntaxhighlight>
 +
  |-
 +
  |}
 +
<br />
 +
 +
Place your Autonomous Period code inside this function. The <span class="codeBasic">AuonomousCodePlaceholderForTesting</span><span class="codePunc">()</span> function is only there as a placeholder and can be removed.<br />
 +
 +
During the autonomous period, the robot performs actions autonomously for the length of time specified by the “autonomousDuration(time)” setting. While the robot cannot accept commands from the Transmitter during this time, it still requires that the Transmitter’s signal be present as a safety precaution. <br />
 +
 +
You cannot skip the autonomous period during a competition by shutting the RF Transmitter off. If you shut the RF Transmitter off during the autonomous period, the VEX’s internal timers will pause, potentially causing your robot to enter the User Control period later than it should.<br />
 +
 +
You do not need to use any <span class="keywordB">bIfiAutonomousMode</span> commands when competition programming.<br />
 +
 +
==== Phase 3: Operator Control ====
 +
{| style="font-family:Verdana, Geneva, sans-serif; color:black; background-color:#FFFFFF; text-align:left; font-size:100%;" cellpadding="5%" cellspacing="0" border="0"
 +
  |-
 +
  |<syntaxhighlight lang="ROBOTC">
 +
task usercontrol()
 +
{
 +
  // User control code here, inside the loop
 +
 +
  while(true)
 +
  {
 +
    // This is the main execution loop for the user control program. Each time through the loop
 +
    // your program should update motor + servo values based on feedback from the joysticks.
 +
 +
    // .....................................................................................
 +
    // Insert user code here. This is where you use the joystick values to update your motors, etc.
 +
    // .....................................................................................
 +
 +
    UserControlCodePlaceholderForTesting(); // Remove this function call once you have "real" code.
 +
  }
 +
}
 +
</syntaxhighlight>
 +
  |-
 +
  |}
 +
<br />
 +
 +
Place your User Controlled Period code inside this function. <span class="codeBasic">UserControlCodePlaceholderForTesting</span><span class="codePunc">()</span> is only there for testing and can be removed once you have placed your own code inside of the while(true) loop.<br />
 +
 +
During the operator controlled period, the robot can accept commands from the Transmitter. This segment of code executes immediately after the autonomous period ends. If you shut the Transmitter off during this period you will not increase the length of the Operator Controller period as the Field Control System determines and controls the length of the human player period.<br />
 +
 
 +
|-
 +
|}
 +
<br />
 +
 +
=== Test Your Code ===
 +
{| style="font-family:Verdana, Geneva, sans-serif; color:black; background-color:#FFFFFF; text-align:left; font-size:100%;" width="100%" cellpadding="5%" cellspacing="0" border="0"
 +
|-
 +
|To test your competition code without a field control kit, follow these steps:
 +
 +
#Download code to VEX controller
 +
#Disconnect the programming cable from the VEX controller
 +
#Turn both the VEX and the Transmitter off (if not already)
 +
#Place the VEX robot on a flat surface
 +
#Turn the VEX controller on
 +
#Wait 5 seconds
 +
#Turn the Transmitter on… your Autonomous code should begin, and your User Control code should follow after the correct amount of time has elapsed.
 +
 +
If you are using VEXnet, please see the "Testing with VEXnet" topics under the "Competition with ROBOTC" heading.
 +
|-
 +
|}
 +
<br />
 +
 +
== Testing with Crystals ==
 +
{| style="color:black;" width="100%" cellpadding="5%" cellspacing="0" border="0"
 +
|-
 +
| style="font-family:Verdana, Geneva, sans-serif; color:black; background-color:#FFFFFF; text-align:left; font-size:100%;"|'''There is no “control” channel to signal between the game control / transmitters and the robot. The only control that the robot can detect is whether it is receiving a 75 MHz radio signal. So this is used to control a match.'''
 +
 +
The three states of the match are controlled as follows:
 +
<br />
 +
 +
{| class="parameterTable" cellpadding="5%" style="color:#943634;"
 +
  ! style="background-color:white; border-color:#943634; border-style: solid; border-width: 2px 0px 1px 0px"|Robot
 +
  ! style="background-color:white; border-color:#943634; border-style: solid; border-width: 2px 0px 1px 0px"|75 MHz Transmitter
 +
  ! style="background-color:white; border-color:#943634; border-style: solid; border-width: 2px 0px 1px 0px"|State
 +
  ! style="background-color:white; border-color:#943634; border-style: solid; border-width: 2px 0px 1px 0px"|Description
 +
  |-
 +
  | style="background-color:#efd3d2; border-color:#943634; border-style: solid; border-width: 1px 0px 0px 0px"|'''OFF'''
 +
  | style="background-color:#efd3d2; border-color:#943634; border-style: solid; border-width: 1px 0px 0px 0px"|Off
 +
  | style="background-color:#efd3d2; border-color:#943634; border-style: solid; border-width: 1px 0px 0px 0px"|
 +
  | style="background-color:#efd3d2; border-color:#943634; border-style: solid; border-width: 1px 0px 0px 0px"|
 +
  |-
 +
  | style="background-color:white; border-color:#943634; border-style: solid; border-width: 0px 0px 2px 0px" rowspan="4"|'''ON'''
 +
  | style="background-color:white; border-color:#943634; border-style: solid; border-width: 0px 0px 0px 0px"|Off
 +
  | style="background-color:white; border-color:#943634; border-style: solid; border-width: 0px 0px 0px 0px"|DISABLED
 +
  | style="background-color:white; border-color:#943634; border-style: solid; border-width: 0px 0px 0px 0px"|
 +
  |-
 +
  | style="background-color:#efd3d2; border-color:#943634; border-style: solid; border-width: 0px 0px 0px 0px"|On
 +
  | style="background-color:#efd3d2; border-color:#943634; border-style: solid; border-width: 0px 0px 0px 0px"|AUTONOMOUS
 +
  | style="background-color:#efd3d2; border-color:#943634; border-style: solid; border-width: 0px 0px 0px 0px"|VEX master CPU is internally timing the autonomous mode (20 seconds). When timer expires it will switch to USER CONTROL state.
 +
  |-
 +
  | style="background-color:white; border-color:#943634; border-style: solid; border-width: 0px 0px 0px 0px"|Off
 +
  | style="background-color:white; border-color:#943634; border-style: solid; border-width: 0px 0px 0px 0px"|DISABLED
 +
  | style="background-color:white; border-color:#943634; border-style: solid; border-width: 0px 0px 0px 0px"|
 +
  |-
 +
  | style="background-color:#efd3d2; border-color:#943634; border-style: solid; border-width: 0px 0px 2px 0px"|On
 +
  | style="background-color:#efd3d2; border-color:#943634; border-style: solid; border-width: 0px 0px 2px 0px"|USER CONTROL
 +
  | style="background-color:#efd3d2; border-color:#943634; border-style: solid; border-width: 0px 0px 2px 0px"|VEX master CPU is internally timing the user control mode (120 seconds). When timer expires it will switch to DISABLED state.
 +
  |-
 +
  |}
 +
<br />
 +
 +
It’s very easy to simulate a Competition match without the need for any additional hardware. Just do the following:
 +
#Start with ROBOT and Transmitter powered off.
 +
#Turn on the ROBOT. User’s pre-autonomous code will run and the “competition” will be in a disabled stated.
 +
#Turn on the transmitter. Robot will run autonomous code. After 20 seconds, the robot will run USER CONTROL code.
 +
#Repeat steps 1 to 3 to simulate another match.
 +
 +
The timing for AUTONOMOUS (20 seconds) and USER CONTROL (120 seconds) is specified via special “#pragma” statements found at the start of your program. See the "Competition Template" page for more information.
 +
 +
Anytime you would like to re-test your competition code, make sure to start from step #1, or else the competition template may not execute correctly.
 +
|-
 +
|}
 +
<br />
 +
 +
== Testing with VEXnet - Manual ==
 +
{| style="color:black;" width="100%" cellpadding="5%" cellspacing="0" border="0"
 +
|-
 +
| style="font-family:Verdana, Geneva, sans-serif; color:black; background-color:#FFFFFF; text-align:left; font-size:100%;"|Innovation First has developed a simple “manual” switch that enables a team to simulate the stages of a competition. There are two manual two-position switches:
 +
 +
*One switch toggles between DISABLED and one of the two operational states.
 +
*The second switch controls whether the robot is in AUTONOMOUS or USER CONTROL (Driver) mode.
 +
<br />
 +
[[File:vex2_competition_vexnet.png]]
 +
|-
 +
|}
 +
<br />
 +
 +
== Testing with VEXnet - Debugger ==
 +
{| style="color:black;" width="100%" cellpadding="5%" cellspacing="0" border="0"
 +
|-
 +
| style="font-family:Verdana, Geneva, sans-serif; color:black; background-color:#FFFFFF; text-align:left; font-size:100%;"|In ROBOTC you can directly simulate a VEXNET match from the ROBOTC debugger. The VEXNET transmitter needs to be connected via the orange programming cable to your PC for the debugger to function.
 +
 +
 +
The ROBOTC IDE has a new window that allows you to put your robot into any one of the three competition states.
 +
<br />
 +
[[File:vex2_competition_vexnet_debugger.png]]
 +
<br />
 +
Simply clicking on any of the three buttons will put your robot into the appropriate state.
 +
 +
 +
''NOTE:'' There is no duration timing when in this mode. To transition from AUTONOMOUS to USER CONTROL you need to click the “User Control” button.  The VEXNET firmware will not perform timing and invoke the transition.
 
|-
 
|-
 
|}
 
|}
 
<br />
 
<br />

Latest revision as of 16:25, 30 April 2012

CORTEX → Competition Overview


There are three possible configurations that can be used to test your ROBOTC program for a VEX Competition.
  1. Using legacy 75 MHz crystals for wireless communications between transmitters and robot.
  2. Using the new VEXNET for wireless communications. And the manual switch competition emulator
  3. Using the new VEXNET for wireless communication. And the ROBOTC IDE connected via orange cable for competition testing.

Each of these is discussed in the next set of pages.

There are three states that need to be handled in a user’s competition program. These are:

State Explanation
DISABLED The robot is DISABLED. This condition can occur befor the start of either the Autonomous or User Control session. All motors and servos are disabled.
AUTONOMOUS A timed (20 second) duration period. Input from the joysticks is blocked. User program can control motors.
User Control Input from the joysticks is available. User program can control motors and servos.



Competition Template

In normal ROBOTC programming, every program is based around a “task main” function, as shown below:

task main()
{
 
}


In a competition program, things are a little different. To keep things simple, however, a Competition Template program is built into ROBOTC for use in VEX Competitions. The template provides a common starting point for teams when competing in an event. Rather than a single “main” task, the template has three sections, each matched to a specific section of the competition:

  • void pre_auton() – For running code that the robot needs to get “set up” before the competition begins
  • task autonomous() – For code the robot should run during the autonomous period (20 seconds by default)
  • task usercontrol() – For code the robot should run during the user control period (120 seconds by default)

The template and its accompanying “include” file handle the background work for the competition, such as monitoring the duration of each phase during a match, and communicating with the Vex Field Controller. All you need to do is tell the robot what to do in each phase.


Open a Competition Template

To open a competition template:

Go to File, select "New" and select "Competition Template"
Open comp 1.png
Note: The competition template is a read-only file, so be sure to save a copy of the file somewhere else on your computer.


Set Up Competition Control and Timing

#pragma competitionControl(Competition)
#pragma autonomousDuration(20)
#pragma userControlDuration(120)


With ROBOTC, the competition control is completely user defined and controlled via software, so there are no jumpers required for testing. By changing these settings, the template can be adapted to work with any competition. The three lines above set the VEX controller into the “competition” mode and specify the timing for the match.

#pragma competitionControl(competition_mode) – Controls the Competition mode that the Vex robot will function in. There are two different competition modes that you can pass to this statement:

  • OFF – Standard setting. No competition controls.
  • Competition – Competition mode. The VEX will respond to Field Controller commands and switch between Autonomous and User Control modes at the competition-specified times. Use this mode for competitions.

#pragma autonomousDuration(time_in_seconds) - Defines the duration of the autonomous phase of a VEX competition. Poor performance may result if this setting does not match the Field Controller settings.

#pragma userControlDuration(time_in_seconds) - Defines the duration of the user control phase of a VEX competition. Poor performance may result if this setting does not match the Field Controller settings.



Program and Test Competition Code

Phase 1: Pre-Competition

void pre_auton()
{
  // All activities that occur before the competition starts
  // Example: clearing encoders, setting servo positions, ...
}


Place your initialization code inside this function.
During the pre-competition section, code can be executed to configure your robot before the competition begins. Valid code for this section includes tasks such as configuring sensors, setting up reflected motors and setting initial servo positions.

Phase 2: Autonomous

task autonomous()
{
  // .....................................................................................
  // Insert user code here.
  // .....................................................................................
 
  AutonomousCodePlaceholderForTesting();  // Remove this function call once you have "real" code.
}


Place your Autonomous Period code inside this function. The AuonomousCodePlaceholderForTesting() function is only there as a placeholder and can be removed.

During the autonomous period, the robot performs actions autonomously for the length of time specified by the “autonomousDuration(time)” setting. While the robot cannot accept commands from the Transmitter during this time, it still requires that the Transmitter’s signal be present as a safety precaution.

You cannot skip the autonomous period during a competition by shutting the RF Transmitter off. If you shut the RF Transmitter off during the autonomous period, the VEX’s internal timers will pause, potentially causing your robot to enter the User Control period later than it should.

You do not need to use any bIfiAutonomousMode commands when competition programming.

Phase 3: Operator Control

task usercontrol()
{
  // User control code here, inside the loop
 
  while(true) 
  {
    // This is the main execution loop for the user control program. Each time through the loop
    // your program should update motor + servo values based on feedback from the joysticks.
 
    // .....................................................................................
    // Insert user code here. This is where you use the joystick values to update your motors, etc.
    // .....................................................................................
 
    UserControlCodePlaceholderForTesting(); // Remove this function call once you have "real" code.
  }
}


Place your User Controlled Period code inside this function. UserControlCodePlaceholderForTesting() is only there for testing and can be removed once you have placed your own code inside of the while(true) loop.

During the operator controlled period, the robot can accept commands from the Transmitter. This segment of code executes immediately after the autonomous period ends. If you shut the Transmitter off during this period you will not increase the length of the Operator Controller period as the Field Control System determines and controls the length of the human player period.


Test Your Code

To test your competition code without a field control kit, follow these steps:
  1. Download code to VEX controller
  2. Disconnect the programming cable from the VEX controller
  3. Turn both the VEX and the Transmitter off (if not already)
  4. Place the VEX robot on a flat surface
  5. Turn the VEX controller on
  6. Wait 5 seconds
  7. Turn the Transmitter on… your Autonomous code should begin, and your User Control code should follow after the correct amount of time has elapsed.

If you are using VEXnet, please see the "Testing with VEXnet" topics under the "Competition with ROBOTC" heading.


Testing with Crystals

There is no “control” channel to signal between the game control / transmitters and the robot. The only control that the robot can detect is whether it is receiving a 75 MHz radio signal. So this is used to control a match.

The three states of the match are controlled as follows:

Robot 75 MHz Transmitter State Description
OFF Off
ON Off DISABLED
On AUTONOMOUS VEX master CPU is internally timing the autonomous mode (20 seconds). When timer expires it will switch to USER CONTROL state.
Off DISABLED
On USER CONTROL VEX master CPU is internally timing the user control mode (120 seconds). When timer expires it will switch to DISABLED state.


It’s very easy to simulate a Competition match without the need for any additional hardware. Just do the following:

  1. Start with ROBOT and Transmitter powered off.
  2. Turn on the ROBOT. User’s pre-autonomous code will run and the “competition” will be in a disabled stated.
  3. Turn on the transmitter. Robot will run autonomous code. After 20 seconds, the robot will run USER CONTROL code.
  4. Repeat steps 1 to 3 to simulate another match.

The timing for AUTONOMOUS (20 seconds) and USER CONTROL (120 seconds) is specified via special “#pragma” statements found at the start of your program. See the "Competition Template" page for more information.

Anytime you would like to re-test your competition code, make sure to start from step #1, or else the competition template may not execute correctly.


Testing with VEXnet - Manual

Innovation First has developed a simple “manual” switch that enables a team to simulate the stages of a competition. There are two manual two-position switches:
  • One switch toggles between DISABLED and one of the two operational states.
  • The second switch controls whether the robot is in AUTONOMOUS or USER CONTROL (Driver) mode.


Vex2 competition vexnet.png


Testing with VEXnet - Debugger

In ROBOTC you can directly simulate a VEXNET match from the ROBOTC debugger. The VEXNET transmitter needs to be connected via the orange programming cable to your PC for the debugger to function.


The ROBOTC IDE has a new window that allows you to put your robot into any one of the three competition states.
Vex2 competition vexnet debugger.png
Simply clicking on any of the three buttons will put your robot into the appropriate state.


NOTE: There is no duration timing when in this mode. To transition from AUTONOMOUS to USER CONTROL you need to click the “User Control” button. The VEXNET firmware will not perform timing and invoke the transition.