NavX -180 180 problem

image

SmartDashboard.putNumber("gyroYaw", ahrs.getYaw());
SmartDashboard.putNumber("getHeading", getHeading());

The value I get from NavX is between -180 and 180, both methods give the same values -180 to 180.

how do i fix this if i need to calibrate navx how do i do it. .:slight_smile:

iirc, I believe you can do “ahrs.GetRotation2d().getDegrees()”

The NavX getAngle method instead returns a continuous value, instead of -180 to +180.

I worry you’re not on the right track here. Take a look at Coordinate System - Rotation Conventions. I would question why you don’t want the values to be in the range (-180, 180].

More importantly, NavX rotation is CW+, which is the opposite of the convention used by other WPILib classes. You probably either want to use getRotation2d(), which inverts the value for you, or you want to invert the returned value from getAngle() or getYaw().

From our 2022 robot’s code:

public double getHeading() {
  return Math.IEEEremainder(gyro.getAngle(), 360.0d) * -1.0d;
}

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.