Cortex VEXnet Manuel d'instructions Page 36

  • Télécharger
  • Ajouter à mon manuel
  • Imprimer
  • Page
    / 95
  • Table des matières
  • DEPANNAGE
  • MARQUE LIVRES
  • Noté. / 5. Basé sur avis des utilisateurs
Vue de la page 35
ROBOTC
ROBOTC Programming - Competition Templates 6
©
2011 Carnegie Mellon Robotics Academy / For use with VEX Robotics Systems
#pragma config(Sensor, in1, bumper, sensorTouch)
//*!!Code automatically generated
#pragma platform(VEX)
#pragma competitionControl(Competition)
#pragma autonomousDuration(20)
#pragma userControlDuration(120)
#include “Vex_Competition_Includes.c”
void forwardUntilTouch()
{
while(SensorValue[bumper] == 0)
{
motor[port2] = 63;
motor[port3] = 63;
}
motor[port2] = 0;
motor[port3] = 0;
}
void pre_autonomous()
{
bMotorReflected[port2] = true;
}
task autonomous()
{
forwardUntilTouch();
motor[port6] = 31;
wait1Msec(250);
motor[port6] = 0;
}
task usercontrol()
{
while(true)
{
motor[port2] = vexRT[Ch2];
motor[port3] = vexRT[Ch3];
motor[port6] = vexRT[Ch6]/4;
}
}
Sample Competition Template with User Code
MotorsandSensorsconguredusing
theROBOTCMotors and Sensors
setupwindowwillautomaticallybe
addedaspragmastatementsatthe
topoftheprogram.
Whileit’snottechnicallyrequired,
it’sgoodprogrammingpracticeto
placeuser-denedfunctionsand/or
globalvariablesbelowthepragma
andincludestatements,andabovethe
template-includedfunctionsandtasks.
ThissetsthemotorconnectedtoVEX
Port2tospininreverse.
Commandsintheautonomousperiod
areexecutedonce(assumingthereareno
loopsinthecode).Also,noticethatthe
AutonomousCodePlaceholder-
ForTestingfunctionhasbeenremoved.
Commandsinthewhile(true)
loopoftheusercontrolperiod
areexecuteduntiltheendof
thematch.Also,noticethatthe
UserControlCodePlaceholder-
ForTestingfunctionhasbeen
removedfromtheloop.
ROBOTC Programming Competition Templates (cont.)
VEX ROBOTICS COMPETITION
Vue de la page 35
1 2 ... 31 32 33 34 35 36 37 38 39 40 41 ... 94 95

Commentaires sur ces manuels

Pas de commentaire