Problem with the V5 Inertial Sensor

I have a problem with my Inartial Sensor. Every time I make my robot turn in my autonomous code it just keeps spining.

void TurnRight (int velocity, double angle) {
  Drivetrain.setHeading(0, degrees); 
  Drivetrain.setDriveVelocity(velocity, percent);
  Drivetrain.turnToHeading(angle-2.5, degrees);
  Brain.Screen.print(Drivetrain.heading(degrees)); 
}

void TurnLeft (int velocity, double angle) {
  Drivetrain.setHeading(0, degrees); 
  Drivetrain.setDriveVelocity(velocity, percent);
  Drivetrain.turnToHeading(360-angle+2, degrees);
  Brain.Screen.print(Drivetrain.heading(degrees)); 
}

That’s often an indication that drivetrain motors are reversed. The code behind turnToHeading assumes the robot needs to turn right (clockwise) to increase the heading value (ie. 0->90 etc.), if the robot actually turns left it will be confused. so try something simple, Drivetrain.turnToHeading(90, degrees) and make sure the robot turns clockwise.

6 Likes