Reset navX roll

Is there a way to zero the navx roll midgame?

Yaw (z axis rotation angle): yes

Roll and Pitch (x and y axis rotation angles): no

See this page for detailed description of these terms.

Roll/Pitch angle does not drift over time - can you please explain why you would like to reset it, and what you would reset it to?

While I don’t think it’s supported by navx, you can get around and effectively reset. I would do this by having a reset method which reads the current roll and sets it to a variable (lets say lastResetRoll). Then just subtract lastResetRoll from the current roll whenever you access roll and you have an effectively “reset” roll.

Our readouts say differently. Not buy much, but about .05 degree a second. We are trying to tell if we are on the ramps of the obstacles. I know it isn’t much but it also doesn’t equal 0 when we are on the ground.

Since it’s reported to you as a float, it will never exactly equal zero. Floating point numbers aren’t exact, they are only approximations, so you can never use an == comparison on floats or doubles and expect it to work.

The NavX is performing a sensor fusion algorithm which combines accelerometer and gyro data. When the robot is not moving, the accelerometers will read a constant 1G vector due to gravity, and this vector can be used to trim the pitch/roll readings even with zero gyro movement so they are exact. While moving, the estimated pitch/roll reading can be used to subtract gravity and get vehicle accelerations from an accelerometer reading both gravity and vehicle accelerations.

The ‘drift’ you’re seeing is probably the error in the gyros being slowly corrected by the accelerometers.

There’s also the possibility that you aren’t truly flat on the ground, since e.g. a 6wd drop center will have a few degrees of normal chassis rock.

Here, try something like this.