A question about the first generation of navx

Our team uses the first generation of navx to serve as the gyro on our swerve. But it seems that when we use the field-oriented mode , it seems that l can’t do it perfectly. l think that my code is correct . Maybe the problem is our gyro(navx) is too old. For example , does navx support the setFusedHeading()? l think that the robot angle must be continuous , it seems that getAngle() can do it , but when l test it on my swerve. The result is very strange.

Any help is appreciated!

I am not positive as I cannot find anything about the Navx1 (v the Navx2), but for the Navx2, I think the method you are looking for is getFusedHeading() the setter would be the desired heading (the difference between getFusedHeading() and the desired heading would be the error in a PID loop).

My understanding is the gyros have few setters (save for calibration) as they mostly read data and push it back to the robot program. Again, I could be totally mistaken with all of this.

Edit: Here is a link to the Navx AHRS Class Documentation (again, this is for the NAVX v2)

The NavX2 improves on the speed and algorithms over the original NavX. This comes from the upgraded micro on the boards. The API is still the same between the two.

The issue with the fused heading not working could be the fact that the magnetometer has not been calibrated. For fused heading to work correctly this must be done. Kauai Labs documentation on calibrating the magnetometer can be found here.

Thanks a lot. l do have used the getFusedHeading() . But after reading the navx’s api, it seems that it doesn’t have the setFusedHeading. However , l use a temporary variable to read the FusedHeading when l enable the telop and subtract it from the GetFusedHeading() when l want to get the robot angle. However, it doesn’t work too.

  • Now , my swerve will work in field-oriented mode only when l turn it 180 degree. l have put the navx’s Yaw value on shuffleboard , it seems that it will soon increase from 0 or 1 around to 180 around , no matter how slow l rotate my robot , the result is the same . So, l just wonder whether there is something wrong with the firm of NavX. Can you help me with it?

Thanks . l just want to get the robot angle through navx and achieve field-oriented. It seems that the GetYaw will also do the same thing. But , does it need to be continuous?

To achieve full field-oriented controls, it is probably best to ZeroYaw at the beginning of the match, and then use GetYaw to determine adjustment -180 to 180 degrees. Are you using an FRC class for your swerve drive, or did you code it from scratch?

l do zeroYaw at the beginning and l use FRC class.

The FRC provides class only flips the controls when the robot rotates 180 degrees. It is based on the alliance sides, not absolute field-orientation. You can solve this problem with a wrapper function. I modify my joystick inputs based on the getYaw() before passing them into the drive class. Does that make sense? I apologize for the delay; I’ve had finals this week

1 Like