I am trying to get my robot to turn to the angle “Goal” simultaneously while driving when R1 is being pressed. Right now I can only do one at a time. Any suggestions? I am currently using a two motor drive if that helps.
while (1) {
if (Controller1.ButtonR2.pressing()){
Brain.Screen.print(Goal);
}
if (Controller1.ButtonL1.pressing()){
Brain.Screen.clearScreen();
Brain.Screen.setCursor(1,1);
}
if (Controller1.ButtonR1.pressing()){
RightMotor.setVelocity(100,percent);
LeftMotor.setVelocity(100,percent);
RightMotor.spin(reverse);
LeftMotor.spin(forward);
waitUntil(OrientationDegrees > Goal - 1 or OrientationDegrees < Goal +1);
RightMotor.stop();
LeftMotor.stop();
}
RightMotor.spin(forward, Controller1.Axis3.value() - Controller1.Axis1.value(), velocityUnits::pct);
LeftMotor.spin(forward, Controller1.Axis3.value() + Controller1.Axis1.value(), velocityUnits::pct);
You should probably use something else that isn’t the waitUntil function. The wait until, obviously, waits until the rotation finishes before allowing any input from you. You can probably do spinFor, and make sure you put “, false” at the end to disable wait for completion to allow you to run it simultaneously.