Difference between revisions of "VEX2 Competition"
Revision as of 16:24, 30 April 2012
|There are three possible configurations that can be used to test your ROBOTC program for a VEX Competition.
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:
In normal ROBOTC programming, every program is based around a “task main” function, as shown below:
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:
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:|
Set Up Competition Control and Timing
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:
#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
Place your initialization code inside this function.
Phase 2: Autonomous
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
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:
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:
It’s very easy to simulate a Competition match without the need for any additional hardware. Just do the following:
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:
Testing with VEXnet - Debugger