I recreated the code and copied the relevant code - hope this helps
Thanks again!
void usercontrol( void ) {
//EVOKE TASKS
vex::task t(tArm); //start arm task
t.setPriority(6); //medium priority
vex::task d(tDrive); //start drive task
d.setPriority(6); //medium priority
while(1){
}
}
int tDrive(){
while (1){
//DRIVE
LR.spin(directionType::fwd, (Controller1.Axis1.value() + Controller1.Axis2.value())*adjSpeed, velocityUnits::pct);
RR.spin(directionType::fwd, (Controller1.Axis1.value() - Controller1.Axis2.value())*adjSpeed, velocityUnits::pct);
LF.spin(directionType::fwd, (Controller1.Axis1.value() + Controller1.Axis2.value())*adjSpeed, velocityUnits::pct);
RF.spin(directionType::fwd, (Controller1.Axis1.value() - Controller1.Axis2.value())*adjSpeed, velocityUnits::pct);
}
return 0;
}
int tArm(void){ //ARM & GRABBER CONTROL TASK
while(1){
if(Controller1.Axis3.value()>deadBand){ //ATTEMPT TO SIMULATE A 4-BAR ARM/CLAW - NOT PERFECT ESP GOING DOWN
GrabberArm.rotateTo(LeftArm.rotation(rotationUnits::deg)*adjGrab,rotationUnits::deg);
LeftArm.spin(vex::directionType::fwd, Controller1.Axis3.value()*0.5, vex::velocityUnits::rpm);
RightArm.spin(vex::directionType::fwd, Controller1.Axis3.value()*0.5, vex::velocityUnits::rpm);
}else if(Controller1.Axis3.value()<deadBand*-1){
LeftArm.spin(vex::directionType::fwd, Controller1.Axis3.value()*0.5, vex::velocityUnits::rpm);
RightArm.spin(vex::directionType::fwd, Controller1.Axis3.value()*0.5, vex::velocityUnits::rpm);
GrabberArm.rotateTo(LeftArm.rotation(rotationUnits::deg)*(adjGrab*0.7),rotationUnits::deg);
}else if(Controller1.ButtonL1.pressing()){
rGrab(50,20,1);
}else if(Controller1.ButtonL2.pressing()){
rGrab(-50,20,1);
}else if(Controller1.ButtonLeft.pressing()){
lowCap();
}else if(Controller1.ButtonRight.pressing()){
highCap();
}else if(Controller1.ButtonUp.pressing()){
loadBall();
}else if(Controller1.ButtonDown.pressing()){
flipCap(); //******** THIS IS THE OFFENDING CODE
}else if(Controller1.ButtonR1.pressing()){
punchBall();
}else{
LeftArm.stop(brakeType::hold);
RightArm.stop(brakeType::hold);
GrabberArm.stop(brakeType::hold);
}
vex::task::sleep(20);
}
return 0;
}//end tArm
void flipCap(void){ //HERE'S THE PROBLEM FUNCTION
d.Stop(); //stop drive task
rArm(100,50,0);
vex::task::sleep(200);
rDrive(100,-100,50,50,1); //IF BLOCKING ROBOT LOCKS UP, NOT IT DOES NOTHING
vex::task::sleep(50);
vex::task d(tDrive); //start task
d.setPriority(6); //medium priority
}//end lift cap
void rDrive(double lDeg, double rDeg, int l, int r, bool b){
LR.rotateFor(lDeg, vex::rotationUnits::deg,l, vex::velocityUnits::pct, false); //This command must be non blocking.
LF.rotateFor(lDeg, vex::rotationUnits::deg,l, vex::velocityUnits::pct, false); //This command must be non blocking.
RR.rotateFor(rDeg, vex::rotationUnits::deg,r, vex::velocityUnits::pct, false); //This command must be non blocking.
RF.rotateFor(rDeg, vex::rotationUnits::deg,r, vex::velocityUnits::pct,b); //This command is blocking so the program will wait here until the right motor is done.
vex::task::sleep(50);
}//end eDrive
void rArm(double deg, int s, bool b){
LeftArm.rotateFor(deg, vex::rotationUnits::deg,s, vex::velocityUnits::pct, false); //This command must be non blocking.
RightArm.rotateFor(deg, vex::rotationUnits::deg,s, vex::velocityUnits::pct,b); //This command is blocking so the program will wait here until the right motor is done.
}//end eArm