Unexpected Behavior with Inertial Sensor Values

I’ve encountered an interesting behavior in VEXcode V5 Text that I’d like to verify with others. When using the inertial sensor’s heading() function, I’m getting inconsistent readings between program runs.

The sensor is properly calibrated at startup, but the values seem to drift differently each time, even when the robot is stationary.

Here’s my test setup:

  • V5 Brain running latest firmware
  • Inertial sensor on port 1
  • Simple program that prints heading values every 100ms

Has anyone else experienced this? I’m curious if this is expected behavior or if there’s a specific way to handle the inertial sensor readings more reliably.

Whoops never mind I found the answer! It seem that the behavior with the inertial sensor’s heading() function is normal.

Inertial sensors typically need a reset and calibration period at the start of each program run to establish a reliable reference point.

I also found a reliable approach:

// Initialize and calibrate
inertial.calibrate();
while(inertial.isCalibrating()) {
    wait(100, msec);
}
// Now readings will be consistent
inertial.resetHeading();
1 Like