Hi everyone,
This weekend our team (5871A) encountered the weirdest bug. We have a function, called flipClaw(), that flips our claw 180º in order to swap the color of caps. This function works perfectly in auto, both on the field and with a competition switch. However, in user control, it works on the competition switch, but not on the field. We are using V5.
Here is the function (claw flipped is just a boolean):
void flipClaw(){
clawFlipped = !clawFlipped;
if(clawFlipped){
Spinner.startRotateTo(180, rotationUnits::deg, 50, percent);
}else{
Spinner.startRotateTo(0, rotationUnits::deg, 50, percent);
}
}
Here is where we call it in auto:
void autonomous( void ) {
wristDown();
sixBarDown();
driveInches(23.5, 50);
task::sleep(200);
turnDegrees(45, 25);
driveInches(25, 50);
wristMiddle();
task::sleep(200);
sixBarUp();
flipClaw();
driveInches(-25,25);
task::sleep(200);
turnDegrees(45, 25);
driveInches(16, 15);
wristDown();
task::sleep(1000);
driveInches(-14, 60);
LiftLeft.startRotateTo(50, rotationUnits::deg, 60, percent);
LiftRight.startRotateTo(50, rotationUnits::deg, 60, percent);
wristUp();
strafeInches(-12, 60);
driveInches(-28, 60);
}
And here is where we call it in user control:
void usercontrol( void ) {
j.ButtonR1.pressed(wristUp);
j.ButtonX.pressed(wristMiddle);
j.ButtonR2.pressed(wristDown);
j.ButtonL1.pressed(sixBarUp);
j.ButtonL2.pressed(sixBarDown);
j.ButtonA.pressed(flipClaw);
while(true) {
strafeControl();
if(j.ButtonUp.pressing()){
isAutoRotating = false;
LiftLeft.spin(directionType::fwd, 20, percent);
LiftRight.spin(directionType::fwd, 20, percent);
}else if(j.ButtonDown.pressing()){
isAutoRotating = false;
LiftLeft.spin(directionType::rev, 20, percent);
LiftRight.spin(directionType::rev, 20, percent);
}else if (!isAutoRotating){
LiftLeft.stop(brakeType::hold);
LiftRight.stop(brakeType::hold);
}
}
}