Inertial Sensor Heading Reversing

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.


The sensor is mounted upside down which might play a role.
Does anyone know what’s going on?

The inertial sensor, when calibrated, is determining what left and right are. Try mounting it in a different location or just rotate the sensor 180 degrees if possible.

I’m a bit confused about how this would help, could you elaborate more on what you mean?

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.

3 Likes

Check the IMU dashboard when you see the reversed condition, it sounds like the auto cal feature that determines the IMU initial orientation occasionally decides the sensor is not upside down.

You should see this for an inverted IMU.

imu_cal

-Z is “up” on the cube but Accel Z is +1 (IMU is inverted).

If it looks different (example, +Z is visible) then something went wrong with cal.

5 Likes

The IMU recently reversed again, this is what the dashboard showed:


As you said, it usually looks like this when it’s working properly:

Do you know how I would go about solving this problem?

Er, Z acceleration at -4.0, that’s not good. May be a faulty sensor.
Perhaps send me the code so I can try and reproduce that.

3 Likes