How are your motors defined in your robot config file? If your robot is going “straight backwards” in this code, you probably have some motors defined as reversed.
You may want to attenuate velocity instead of flipping forward / reverse. Velocity is a range from -100 to +100 and direction is binary. If you tell a forward motor to spin at -50 it will spin backward. This way you don’t need to use the if / else to change direction and the motors will dynamically change direction if the value falls below zero.
void driveVelocity(float left, float right) {
left1.spin(forward, left);
left2.spin(forward, left);
left3.spin(forward, left);
right1.spin(reverse, right);
right2.spin(reverse, right);
right3.spin(reverse, right);
}
int onauton_autonomous_0(){
Inertial10.setHeading(0, degrees);
float diff = (Inertial10.heading(degrees)-90);
while (fabs(diff) > 0.01) {
//Whatever your logic is for course correction
int diff = (Inertial10.heading(degrees)-90);
driveVelocity(60-diff, 60+diff);
diff = (Inertial10.heading(degrees)-90);
}
}