For reference here is our Telop code
Code:
void OperatorControl(void)
{
myRobot.SetSafetyEnabled(true);
en1.Reset();
gyro.Reset();
AxisCamera &robocam = AxisCamera::GetInstance();
robocam.WriteResolution((AxisCamera::Resolution_t)3);
robocam.WriteBrightness(0);
Wait(3.0);
while (IsOperatorControl())
{
// read digital inputs
unsigned short leftValue = left->Get() ? 4 : 0; // read the line tracking sensors
unsigned short middleValue = middle->Get() ? 2 : 0;
unsigned short rightValue = right->Get() ? 1 : 0;
//Look for line sensor inputs only when right bumber is pressed
if (xbox.GetRightBumper()){
switch(leftValue + middleValue + rightValue){
case(0x0): // normal operation
case(0x5):
case(0x7):{
//printf("no line found \n");
//void MecanumDrive_Cartesian(float x, float rotation, float y, float gyroAngle = 0.0);
if (!xbox.GetLeftBumper()){
myRobot.MecanumDrive_Cartesian(xbox.GetLeftX(), xbox.GetRightY(), -xbox.GetLeftY(), 0); //Mecanum drive at full speed
}
else{
myRobot.MecanumDrive_Cartesian(xbox.GetLeftX()/2, xbox.GetRightY()/2, -xbox.GetLeftY()/2, 0);//Mecanumdrive at half speed
}
break;
}
case(0x1): // straif right
case(0x3):{
// printf("right leftstickX = %f, abs = %i\n",leftstick.GetX(), abs((int)leftstick.GetX()));
float leftvalue = (fabs(xbox.GetLeftX())/-2);
//printf("right leftstickX = %f\n", leftvalue);
myRobot.MecanumDrive_Cartesian(leftvalue, 0, -xbox.GetLeftX(), 0);
break;
}
case(0x2):{ // keep going
//printf("middle \n");
myRobot.MecanumDrive_Cartesian(0, 0, -xbox.GetLeftX(), 0);
break;
}
case(0x4): // straif left
case(0x6):{
//printf("left \n");
float rightvalue = (fabs(xbox.GetLeftX())/2);
//printf("left leftstickX = %f\n", rightvalue);
myRobot.MecanumDrive_Cartesian(rightvalue, 0, -xbox.GetLeftX(), 0);
break;
}
default:
break;
}
}
else {
//This is how the robot will drive if the right bumper is not pressed
//void MecanumDrive_Cartesian(float x, float rotation, float y, float gyroAngle = 0.0);
if (!xbox.GetLeftBumper()){
myRobot.MecanumDrive_Cartesian(-xbox.GetLeftX(), -xbox.GetRightY(), -xbox.GetLeftY(), 0); //Mecanum drive at full speed
}
else{
myRobot.MecanumDrive_Cartesian(-xbox.GetLeftX()/2, -xbox.GetRightY()/2, -xbox.GetLeftY()/2, 0);//Mecanumdrive at half speed
}
}