We are trying to program our Inertial Sensor but it never work well in our autonomous period. It’s like nothing change with inertial sensor or without inertial sensor.
My first assumption is that the problem is that your robot is overshooting the target. Am I correct? If so, you should implement a PID controller on your drive. As of now, even if your robot is only 0.00001 degrees away from the target, it is still going at max speed. Robots cannot stop immediately, so your robot will inevitably go past where it was supposed to. A PID controller aims to smooth out the velocity of your drive so that it comes to a nice clean stop. Please read this article by George Gillard IN ITS ENTIRETY. It is extremely helpful, and probably the most popular starting point for learning about PID.
It’s funny that you reset the rotations before each code, I would suspect you would wanna do that in pre auton so that way the headings stay the same.
Idk if you played with turn threshold or turn constant, it should be in the vex library if you don’t wanna try and read that PID guide, it could help a bit.
The Drivetrain has logic included for heading and turning by degrees. You can use turnToHeading and turnFor.
Example:
// Set Drivetrain parameters
Drivetrain.setHeading(0.0, degrees);
Drivetrain.setTurnVelocity(50.0, percent);
Drivetrain.setDriveVelocity(50.0, percent);
//Make sure the Drivetrain has enough time to make the move.
Drivetrain.setTimeout(5.0, sec);
//Drive forward
Drivetrain.driveFor(forward, 12.0, inches, true);
// Turn with heading
Drivetrain.turnToHeading(45.0, degrees, true);
// Turn with direction and degrees
Drivetrain.turnFor(right, 45.0, degrees, true);