Inertial Sensor Turns

My team has been using the inertial sensor for turning throughout this season. We just made a new robot and we are starting to code it. I am using the exact same functions, but the robot just keeps turning. I do not know what to change since the code worked on the other robot. Does anyone have any suggestions?
'void turnRightPoint(double turnAmount, double speed){ //method for a right point turn

/*resets the rotation that the sensor is at
so it can do a bunch of tasks in a row without pausing
*/
inertial4.resetRotation();

/sets each motor to the velocity specified in the method,
negative for the left side since it’s a point turn
/

bLeft.setVelocity(-speed,vex::velocityUnits::pct);
mLeft.setVelocity(-speed,vex::velocityUnits::pct);
fLeft.setVelocity(-speed,vex::velocityUnits::pct);
bRight.setVelocity(speed,vex::velocityUnits::pct);
mRight.setVelocity(speed,vex::velocityUnits::pct);
fRight.setVelocity(speed,vex::velocityUnits::pct);

fRight.spin(directionType::fwd);
mRight.spin(directionType::fwd);
bRight.spin(directionType::fwd);

fLeft.spin(directionType::fwd);
mLeft.spin(directionType::fwd);
bLeft.spin(directionType::fwd);

/* each of the motors will spin until the inertial
reaches the desired amount in degrees*/

waitUntil(inertial4.rotation(degrees)>=turnAmount);

//all motors stop once turn amount is reached
fRight.setVelocity(0,vex::velocityUnits::pct);
mRight.setVelocity(0,vex::velocityUnits::pct);
bRight.setVelocity(0,vex::velocityUnits::pct);
fLeft.setVelocity(0,vex::velocityUnits::pct);
mLeft.setVelocity(0,vex::velocityUnits::pct);
bLeft.setVelocity(0,vex::velocityUnits::pct);

}’

1 Like

Is it turning quickly or slowly? If it’s a really slow turn it might be inertial sensor drift.

don’t forget to format your code by pasting it in between two of these:```

as in code sample

1 Like

you might also want to create a function with parameters for turning direction and the degree you want to head to. I made one and had various if else statements that determined what to do based on the position of the robot on the 0-359.999 degree circle. For example, when the robot is at 330 and you want to turn right to 20, you would need a series if-else statements to determine what to do when the degree resets to zero and the existing while statement doesn’t work. If anyone has any questions just reach out.