If you are using the newer version of ROBOTC for VEX Robotics 4.X, there is one potential issue that you may have run into; the driveLeft and driveRight keywords are now used to describe the left and right side drivetrain motors, as set up in the Motors and Sensors Setup, and will generate errors when used as function names/variable names in ROBOTC.
I updated your current code in case you are running ROBOTC 4.0, to avoid any issues with it in the future:
void leftDrive(int fwd)
{
int fwdCmd = 0;
if(abs(fwd) < 15)
fwdCmd = 0;
else
fwdCmd = fwd;
motor[botLeft] = -fwdCmd;
motor[topLeft] = -fwdCmd;
}
void rightDrive(int fwd) {
int fwdCmd = 0;
if(abs(fwd) < 15)
fwdCmd = 0;
else
fwdCmd = fwd;
motor[botRight] = -fwdCmd;
motor[topRight] = -fwdCmd;
}
task usercontrol()
{
while (true)
{
leftDrive(vexRT[Ch3]);
rightDrive(vexRT[Ch2]);
if(vexRT[Btn5U] == 1)
{
motor[clawLift] = 127;
}
else if(vexRT[Btn6U]==1)
{
motor[clawLift] = -127;
}
else
{
motor[clawLift] = 0;
}
if(vexRT[Btn5D] == 1)
{
motor[claw] = 127;
}
else if(vexRT[Btn6D]==1)
{
motor[claw] = -127;
}
else
{
motor[claw] = 0;
}
}
}
However, I did not see any issues with the arm control code; this means there may be an issue with the either the configuration of the robot, or how the code is being executed in the competition template.
First, please run the following code on the robot and use the ‘5U’ and ‘6U’ buttons to control the clawLift motor and let me know what the results are.
#pragma config(Motor, port1, botRight, tmotorVex393, openLoop)
#pragma config(Motor, port2, topLeft, tmotorVex393, openLoop)
#pragma config(Motor, port3, botLeft, tmotorVex393, openLoop)
#pragma config(Motor, port4, topRight, tmotorVex393, openLoop)
#pragma config(Motor, port5, clawLift, tmotorVex393, openLoop)
#pragma config(Motor, port6, claw, tmotorVex393, openLoop)
//*!!Code automatically generated by 'ROBOTC' configuration wizard !!*//
task main()
{
while (true)
{
if(vexRT[Btn5U] == 1)
{
motor[clawLift] = 127;
}
else if(vexRT[Btn6U]==1)
{
motor[clawLift] = -127;
}
else
{
motor[clawLift] = 0;
}
if(vexRT[Btn5D] == 1)
{
motor[claw] = 127;
}
else if(vexRT[Btn6D]==1)
{
motor[claw] = -127;
}
else
{
motor[claw] = 0;
}
}
}
If the code works without any issues, the problem may be with how you are executing the code while using the Competition template; if the code does not work, there may be an issue with how the robot is physically configured. In either case, let us know what the results are and specifically how you are running the code on the robot, how the motor is attached to the robot, if there are any sensors attached to the robotc, etc.