Instead of using the built in turnFor program you can test the inertial sensor with a custom algorithm or just test it in your drive code to ensure that it is properly calibrated and reading values.
An example of a custom algorithm to test the inertial sensor is:
//tHeading(desired turn angle, turn direction, tolerance, speed of turn)
void tHeading(double angD, bool lr,double tolerance, double fastness){
double lrNum = 0;
double angS = motion.heading(degrees);
while (!(((angD - tolerance) < motion.heading(degrees)) && (motion.heading(degrees) < (angD + tolerance)))){
if(lr){
FL.spin(forward, perc, percent);
BL.spin(forward, perc, percent);
ML.spin(forward, perc, percent);
FR.spin(reverse, perc, percent);
BR.spin(reverse, perc, percent);
MR.spin(reverse, perc, percent);
}else{
FL.spin(reverse, perc, percent);
BL.spin(reverse, perc, percent);
ML.spin(reverse, perc, percent);
FR.spin(forward, perc, percent);
BR.spin(forward, perc, percent);
MR.spin(forward, perc, percent);
}
}
FL.stop();
ML.stop();
BL.stop();
FR.stop();
MR.stop();
BR.stop();
}
If you don’t want to implement that then simply add something like this to your while loop in your user control:
Controller1.Screen.setCursor(0,0);
Controller1.Screen.print(motion.heading(degrees));
If you end up finding that the inertial sensor itself isn’t reading correctly then you can try putting the entire inertial code into a while loop or switching to a different compiler like VSC. Good luck and please reply if you have any other questions.