Function not working in user control

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);
        }
    }
}

Alright, I found the issue. In our pre auton, we use the rotateTo function on our flipping motor. This somehow locks us out of being able to flip the claw.

Add a “, False” (no quotes) at the end of your rotateTo list of params, this will still move your motor to where you want, but will not halt everything and will not wait for it to get there, allowing you to do other things and spin other motors. Just note that if you have another command that spins the same motor right after, it will interrupt the first action and move to the new command (there’s a way around that using a built in variable that checks if the motor finished).

We just use the .startRotateTo(…) instead. Is there any known difference?

Based on the documentation I’ve seen, there is no real difference between .startRotateTo(…) and .rotateTo(… , false).

There isn’t
startRotateTo is just a small wrapper function.