COMPETITION TEMPLATE
Unfortunately all of the codes we have written up to this point are illegal in competition. Don’t get too angry at me right now because the codes you just wrote are easily transferable into the competition template. The way we have run projects before is solely for TESTING AND EASY DEBUGGING. To create a file for the competition go to File -> New -> Competition Template. For the competition template you must primarily be concerned with two methods “task autonomous()” and “task usercontrol().” The autonomous task is called when the autonomous period of the competition starts. RobotC will pretend it is starting a new file and uses “task autonomous()” as if it is was “task main()” from our other tutorials. Hence, when the autonomous period starts, the code within “task autonomous()” will run. DO NOT PLACE ANY VEXRT STATEMENTS HERE AS THE AUTONOMOUS PERIOD DOES NOT ALLOW FOR USER REMOTE CONTROL. “task usercontrol ()” is the same as “task autonomous()” but it is called during the driver portion of the competition. You should place all driver control commands into this method (AKA vexRT). Do not worry if the autonomous does not finish when the competition changes to driver control because RobotC automatically shuts off all motors modes are changed (NOTE: CHECK THIS STATEMENT). If you program using the competition template, you must make sure the compiler setting is changed to Robot -> VEX Cortex Communication Mode - > Competition (VEXnet). If you download the code to the robot right now and test it, the robot by default will believe it is in the driver control portion of the competition. To switch between driver control and autonomous to simulate the competition, one must use a competition switch:
(image of a competition switch)
For the competition switch to work, it must be plugged into the back of the main controller:
(image of competition switch plugged into the main controller)
You would turn the robot on as you usually do with the controllers but the switch on the controllers changes if the robot will execute code from “task autonomous()” or “task usercontrol().”
What I highly advise is that you create your autonomous and drive code using the blank template and then copy them into the competition template later so that you may test the codes without a competition switch.
Cheers!
(image of a competition switch)
For the competition switch to work, it must be plugged into the back of the main controller:
(image of competition switch plugged into the main controller)
You would turn the robot on as you usually do with the controllers but the switch on the controllers changes if the robot will execute code from “task autonomous()” or “task usercontrol().”
What I highly advise is that you create your autonomous and drive code using the blank template and then copy them into the competition template later so that you may test the codes without a competition switch.
Cheers!