Programming instructions
ROBOTC
ROBOTC Programming - Competition Templates • 2
©
2011 Carnegie Mellon Robotics Academy / For use with VEX Robotics Systems
ShownbelowarethecontentsoftheCompetition.clewithbriefdescriptions,butwiththecomments
removed.Additionaldetailsareavailablethroughoutthedocument.
#pragma platform(VEX)
#pragma competitionControl(Competition)
#pragma autonomousDuration(20)
#pragma userControlDuration(120)
#include “Vex_Competition_Includes.c”
void pre_autonomous()
{
//Place pre-autonomous code here
}
task autonomous()
{
//Place autonomous code here
AutonomousCodePlaceholderForTesting();
}
task usercontrol()
{
while(true)
{
//Place user control code here
UserControlCodePlaceholderForTesting();
}
}
Thispragmastatementspecies
theVEXastheplatformtype.
Thispragmastatementenables
competitioncontrol.
Thesepragmastatementsspecifythe
duration(20and120seconddefaults)ofthe
autonomousandusercontrolmodesforVEX
PICbasedrobotsusingthe75MHzCrystals.
VEXCortexandVEX1.5(VEXnetUpgraded
PIC)basedrobotswillignoretheselines;
whichmodetheyareinandthedurationare
controlledusingtheeldcontrolsystem.
Thisincludelecontainsthefunctionality
necessaryfortherobottooperatewiththe
VEXeldcontrol.DoNOTmodifytheinclude
leorremovethislineofcode.
Anyinitializationcode,suchassetting
servopositionsorclearingencoder
valuescanbeplacedwithinthe
pre_autonomous()function.
Allcodefortheautonomousportion
ofthecompetitionshouldbeplaced
withintheautonomous task.The
AutonomousCodePlaceholderForTesting
functioncanberemovedonceyouplaceyour
owncodewithinthetask.
Allcodefortheusercontrolportionofthe
competitionshouldbeplacedwithinthewhile()
loopoftheusercontrol task.Thewhile()loop
repeatsallcommandswithinitscurlybrackets
forthedurationoftheusercontrolportionof
thecompetition,ensuringthatthetransmitter
dataandanyothervaluesareup-to-date.The
UserControlCodePlaceholderForTesting
functioncanberemovedonceyouplaceyour
owncodewithinthetask.
3. AnewlenamedCompetition.cwillappear.Beforemakinganychangestothetemplate,gotoFile,
selectSave As...andsavethisprograminalocationandunderanameyouwillremember.
ROBOTC Programming Competition Templates (cont.)
VEX ROBOTICS COMPETITION