Hello Vex Community,
My team is currently working on programming tasks in RobotC. The following code refuses to compile because of undefined variables.
Any help with making our program work would be greatly appreciated.
#pragma config(Sensor, in1, batterylevel, sensorAnalog)
#pragma config(Sensor, in2, liftpoto, sensorPotentiometer)
#pragma config(Sensor, in3, chainbarpoto, sensorPotentiometer)
#pragma config(Sensor, in4, gyroscope, sensorGyro)
#pragma config(Sensor, in5, leftlinefollower, sensorLineFollower)
#pragma config(Sensor, in6, rightlinefollower, sensorLineFollower)
#pragma config(Sensor, dgtl1, rightencoder, sensorQuadEncoder)
#pragma config(Sensor, dgtl3, leftencoder, sensorQuadEncoder)
#pragma config(Sensor, dgtl5, limitswitch, sensorTouch)
#pragma config(Sensor, dgtl6, leftultrasonic, sensorSONAR_inch)
#pragma config(Sensor, dgtl8, rightultrasonic, sensorSONAR_inch)
//*!!Code automatically generated by 'ROBOTC' configuration wizard !!*//
/*---------------------------------------------------------------------------*/
/* */
/* Description: Competition template for VEX EDR */
/* */
/*---------------------------------------------------------------------------*/
// This code is for the VEX cortex platform
#pragma platform(VEX2)
// Select Download method as "competition"
#pragma competitionControl(Competition)
//Main competition background code...do not modify!
#include "Vex_Competition_Includes.c"
/*---------------------------------------------------------------------------*/
/* Pre-Autonomous Functions */
/* */
/* You may want to perform some actions before the competition starts. */
/* Do them in the following function. You must return from this function */
/* or the autonomous and usercontrol tasks will not be started. This */
/* function is only called once after the cortex has been powered on and */
/* not every time that the robot is disabled. */
/*---------------------------------------------------------------------------*/
void pre_auton()
{
// Set bStopTasksBetweenModes to false if you want to keep user created tasks
// running between Autonomous and Driver controlled modes. You will need to
// manage all user created tasks if set to false.
bStopTasksBetweenModes = true;
// Set bDisplayCompetitionStatusOnLcd to false if you don't want the LCD
// used by the competition include file, for example, you might want
// to display your team name on the LCD in this function.
// bDisplayCompetitionStatusOnLcd = false;
// All activities that occur before the competition starts
// Example: clearing encoders, setting servo positions, ...
}
/*---------------------------------------------------------------------------*/
/* */
/* Autonomous Task */
/* */
/* This task is used to control your robot during the autonomous phase of */
/* a VEX Competition. */
/* */
/* You must modify the code to add your own robot specific commands here. */
/*---------------------------------------------------------------------------*/
task autonomous()
{
// ..........................................................................
// Insert user code here.
// ..........................................................................
// Remove this function call once you have "real" code.
AutonomousCodePlaceholderForTesting();
}
/*---------------------------------------------------------------------------*/
/* */
/* User Control Task */
/* */
/* This task is used to control your robot during the user control phase of */
/* a VEX Competition. */
/* */
/* You must modify the code to add your own robot specific commands here. */
/*---------------------------------------------------------------------------*/
task usercontrol()
{
while (true)
{
startTask(autostack);
motor[port8] = vexRT[Ch2]; //prt 8 right y
motor[port2] = vexRT[Ch3]; //prt 2 left y
motor[port3] = vexRT[Ch2]; //prt 3 right single
motor[port9] = vexRT[Ch3]; //prt 9 left single
//button5 (mobile goal intake motors)
if(vexRT[Btn5U] == 1) //mobi intake up
{
startTask(stack);
}
else if(vexRT[Btn5D] == 1) //mobi intake down
{
killTask(stack);
}
else
{
motor[port4] = 0;
}
}
}
}
task stack(){
{
while(true){
motor[port10] = 127;
}
}
}