Rev Robotics Swerve Drive Field Relative Issues

Hi all,

Our team is having some trouble with our field relative sense. Field relative seems to work every 180 degrees. Meaning that if I initially push forward on the joystick and then I rotate 180 degrees and push forward on the stick it will go forward in terms of field relativity. It is when we go in between 0 and 180 degrees that forward on the joystick is not forward. We tried just downloading the rev robotics swerve example code and we had the same issue. Does anyone have any suggestions on how to fix this?

Ah yea, we ran into this same issue - turned out the kGyroReversed value was not being respected in all cases in the example code where the gyro was accessed. Specifically:

Rotation2d.fromDegrees(m_gyro.getAngle())

That snippet appears a lot in the DriveSubsystem, so we pulled it into a helper function and negated that angle value when the gyro is reversed. Hope this helps you all!

2 Likes

What gyro are you using? We had similar symptoms with a navx and switched to ADS and that solved our problem. We never went in to debugging with the navx.

Thank you! It worked for us.

1 Like

I had the same issue. I fixed it by negating the navx value as it counts clockwise positve like a compass, but wpilib classes want counterclockwise positive.