Inertial sensor turning: not turning more than once

hey, I’ve tried to make a simple autom code using the intertial sensor turning from the vex pro example, however the bot wont read the second second intertial turn code, only registering the first inertial turn code fine.
At the moment the the bot simply moves foward and then rotates 90 degrees then skips the second intertial turncode and just goes foward. Why is it not registering the second inertial turn code?

    LeftMotorA.spin(directionType::fwd);
  RightMotorA.spin(directionType::fwd);
  LeftMotorB.spin(directionType::fwd);
  RightMotorB.spin(directionType::fwd);
  task::sleep(500);


  
   LeftMotorA.spin(directionType::fwd);
  RightMotorA.spin(directionType::rev);
  LeftMotorB.spin(directionType::fwd);
  RightMotorB.spin(directionType::rev);
  
  // Waits until the motor reaches a 90 degree turn and stops the Left and
  // Right Motors.
  waitUntil((Inertial15.rotation(degrees) >= 90));
  LeftMotorB.stop();
  LeftMotorA.stop();
  RightMotorB.stop();
  RightMotorA.stop();
  wait(1, seconds);




LeftMotorA.spin(directionType::fwd);
  RightMotorA.spin(directionType::fwd);
  LeftMotorB.spin(directionType::fwd);
  RightMotorB.spin(directionType::fwd);
 task::sleep(500);

 
  LeftMotorA.spin(directionType::fwd);
  RightMotorA.spin(directionType::rev);
  LeftMotorB.spin(directionType::fwd);
  RightMotorB.spin(directionType::rev);
  
  // Waits until the motor reaches a 90 degree turn and stops the Left and
  // Right Motors.
  waitUntil((Inertial15.rotation(degrees) >= 90));
  LeftMotorB.stop();
  LeftMotorA.stop();
  RightMotorB.stop();
  RightMotorA.stop();
  wait(1, seconds);




  LeftMotorA.spin(directionType::fwd);
  RightMotorA.spin(directionType::fwd);
  LeftMotorB.spin(directionType::fwd);
  RightMotorB.spin(directionType::fwd);
   task::sleep(500);
1 Like

I don’t have a lot of experience with the Inertial sensor but my best guess is that the reading on the Inertial sensor is already at 90 degrees, so when you tell the robot to wait until you reach 90 degrees, you’re already at it. You are telling the robot to turn to 90 degrees, not to turn 90 degrees. The difference is that one will turn 90 degrees relative to 0 degrees, and the other will simply turn 90 degrees from any starting position.

What I would do is reset the heading of your sensor before you begin a new turn or right after you complete a turn as a pretty simple solution. Alternatively, you could tell it to turn to 180 degrees after you tell it to turn to 90 degrees.

1 Like

I think AA1353 is on the right track here. Consider using heading instead of rotation, and then you can turn to 90, 180, 270, 0, etc.

hmm, ive tried changing the degrees and nothing still happened but I think ill add in some code to reset the heading of the inertial sensor to see if that makes a difference

1 Like

Let us know if that works since I have a sister team with the same issue.

We are now having the same issue. After the robot makes one pivot, during the next pivot it just spins in place

Update: Resetting the rotations to zero after each pivot fixes the issue

Screenshot 2022-03-02 4.09.50 PM Screenshot 2022-03-02 4.09.31 PM

1 Like