Skip to content
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

navx_frc: AHRS.getRate() doesn't return degrees per second #69

Open
elodotwe opened this issue Feb 12, 2018 · 3 comments
Open

navx_frc: AHRS.getRate() doesn't return degrees per second #69

elodotwe opened this issue Feb 12, 2018 · 3 comments

Comments

@elodotwe
Copy link

elodotwe commented Feb 12, 2018

Contrary to the javadoc, it seems AHRS.getRate() does not return degrees per second. Experimentally, when the robot was spinning at breakneck speeds (>1 rotation per second) with a well-behaved, calibrated NavX (yaw looked correct), the getRate function was returning between 7 and 8, when I expected greater than 360.

Digging into the code, it looks like AHRS.getRate() calls ContinuousAngleTracker.getRate(), which doesn't account for the sample rate of the incoming data:

public double getRate() {
float difference;
synchronized(this) {
difference = curr_yaw_angle - last_yaw_angle;
}
if ( difference > 180.0f) {
/* Clockwise past +180 degrees */
difference = 360.0f - difference;
} else if ( difference < -180.0f) {
/* Counter-clockwise past -180 degrees */
difference = 360.0f + difference;
}
return difference;
}

It seems that somewhere you'd need to take into account the timestamps of the data coming in, or use the set update rate to determine the rotation rate in terms of degrees per second.

I think my sensor was set to 60Hz by default (I didn't change this), so my 7-8 observation would indicate 7*60 = 420DPS to 8*60 = 480 DPS...plausible, I think.

I'm tinkering with fixing this and might submit a pull request if I get the gumption to do so tomorrow.

@kauailabs
Copy link
Owner

Thanks for finding this. Note that you can use the AHRS.getRawGyroZ() method to return a value w/units of degrees second for now.

However this should be fixed. The way to do so is to multiple difference by AHRS.getActualUpdateRate(), yielding the result in degrees/second; let me know if you'd like to contribute the fix for that. Otherwise we'll tackle this after the FRC build season is over.

@camearle20
Copy link

It's been a couple years since this was opened, is there any plan to fix this in a future release?

@truher
Copy link

truher commented Feb 27, 2024

just adding another vote to fix this. i'm sure @kauailabs is very busy; maybe just delete the method with the bug?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants