-
Notifications
You must be signed in to change notification settings - Fork 5.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
imu.getRobotAngularVelocity(AngleUnit.RADIANS) returns degrees instead of radians #1070
Comments
Thank you for reporting this issue! We have investigated and confirm that there is indeed an issue related to your report. We are looking into it now and working on the best path forward to correct it. The issue scope currently involves all unit conversions for getting AngularVelocity from native IMU units. If you ask for a unit different than the native unit of the IMU you are using, it will not be converted. (ie, if your IMU reports natively in RADIANS then it will give you RADIANS if you ask for it in RADIANS or DEGREES. If your IMU reports natively in DEGREES then it will give you DEGREES when you ask for RADIANS or DEGREES.) |
Add workaround for FIRST-Tech-Challenge/FtcRobotController#1070
Thanks for confirming. Is there a way to programmatically determine the IMU's native units? Or, can we assume that all competition IMUs are natively degrees? I'm asking because rbrott implemented the workaround I suggested above in road-runner, but after your description, it sounds like the workaround of just using degrees might only work for specific IMUs. The control hub I am testing with has the BHI260AP IMU, which, according to the specs, reports gyroscope measurements in degrees/s. However, it looks like the BNO55 reports either radians or degrees depending on the UNIT_SEL register. |
Note: A previous version of this comment incorrectly stated that IMU orientation angles would also be affectedBoth the BHI260AP and the BNO055 used through the If you are using a BNO055 through the old |
Fixed in 10.1 |
The original version of my previous comment incorrectly stated that IMU orientation angles would be affected, which is not true. |
Thanks for fixing this. I just confirmed that my original code example listed above is now working as expected with v10.1. I also confirmed that the errant behavior caused by this issue in road-runner is now working as expected both in their unpatched version (0.1.13) and in their patched version (0.1.14). |
It looks like imu.getRobotAngularVelocity always returns the zRotationRate (and presumably the other axes rates) in degrees regardless of the AngleUnit provided to the method. Consider the following code example:
When I run this on a mecanum strafer robot, and rotate the robot left/right, the values printed for both the degrees and radians match and appear to be in degrees.
There appears to be a workaround, which is to use Math.toRadians(imu.getRobotAngularVelocity(AngleUnit.DEGREES).zRotationRate), but several libraries (including RoadRunner) use radians and would need to be updated with this workaround to operate correctly.
The text was updated successfully, but these errors were encountered: