Inertial Sensor Never Stops

void turnR(float deg){
  InertialSensor.calibrate();
  while (InertialSensor.isCalibrating()) {
  wait(100, msec);
  }
  LFM.spin(forward);
  LBM.spin(forward);
  RFM.spin(forward);
  RBM.spin(forward);
  
  waitUntil((InertialSensor.rotation(degrees) >= deg));
  LFM.stop(coast);
  LBM.stop(coast);
  RFM.stop(coast);
  RBM.stop(coast);
}

This is my code for turning right, when i want to write turnR(90.0); robot always turns and never stop. Could anyone help me?

Have you tried reversing the direction the robot spins in? It could be spinning in the wrong direction and never reach 90°.

1 Like

Are you sure you want to calibrate your inertial before every turn?

Why are you spinning all your motors forward if you want to turn?

Try reversing the sign:

Actually, try printing inertial rotation to the brain and turning the robot:

while (true) {
  clearscreen();
  print(inertial.rotation());
  wait(50, msec);
}
5 Likes