Recently our inertial sensor has been outputting opposite values of what it’s supposed to during some runs. For example, when the bot turns 40 degrees to the right, the inertial sensor should output 40 degrees, but sometimes it would output -40 degrees instead.
Once the inertial sensor values becomes reversed, it stays like this for multiple runs. The only way we’ve found to make it go back to normal is to multiply the heading value by -1 as a temporary band-aid solution, and after a few runs it will seemingly randomly start reading normal values again in the middle of a run.
The sensor is calibrated before every run, and to my knowledge, nothing out of place happens before runs where the sensor becomes reversed.
You might want to try yaw instead of heading. The heading function outputs a value between 0 and 360, while rotation, angle and yaw (I think) output the total number of degrees the robot has turned, even if that’s over 360. It’s been a while since I’ve used VEXcode, but I do remember that the heading function didn’t do exactly what I wanted, so I switched to one of the others. I recommend you take a look at the API and then write a program that prints out (to the terminal or brain/controller screen) the values of all four functions, and then move the sensor around and see what the values are so that you can get a better understanding.