V5 Inertial Sensor heading

How do you get the direction the robot is facing using the VEX V5 Inertial Sensor?
I have tried INERTIAL.heading(degrees) and gotten no results other than 0.

you need to calibrate it somewhere else in the code, like this:

INERTIAL.startCalibration();
vex::task::sleep(100);
INERTIAL.calibrate();
while(INERTIAL.isCalibrating()){
  vex::task::sleep(10);
}

you do not need both

INERTIAL.startCalibration();

and

INERTIAL.calibrate();

They do exactly the same thing.

(also, don’t name variables in uppercase, it’s works but not considered a good programming practice for C programmers, save uppercase for definitions)

The IMU will run a calibration automatically every time you run a program, so you may not need that code at all.

VEXcode has example programs that use the IMU, have a look at those.

4 Likes

Thank you. We’ve done that. What’s next?

Thank you. We’ve done that. What’s next? We have used both the Heading command and the Rotations command. We have used two different sensors. All we get back is zeros. We’ve also used the SetHeading command. One new question perhaps: does VEXos play a role in this process?