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

Question on Gyro Angle Wrapping #42

Open
Squid5678 opened this issue Jan 23, 2024 · 1 comment
Open

Question on Gyro Angle Wrapping #42

Squid5678 opened this issue Jan 23, 2024 · 1 comment

Comments

@Squid5678
Copy link

Does 364 have support for wrapping the gyro angle so it fits within the range of [-180, 180)? If not, any recommendations on how to implement this? Would using something from the IEEE library work? @dirtbikerxz

@WOFsoftware51
Copy link

WOFsoftware51 commented Mar 10, 2024

Not sure if this is the best solution, but here's how our team wraps the gryo angle within [0, 360]:

yawFixed = Math.abs((360-gyro.getAngle())% 360);
The "360 - " part might not be necessary for what you want, but it works on our robot so it shouldn't be a problem.
If you want to wrap the angle within [-180, 180], you could just subtract 180 from the equation above.
yawFixed = 180 - Math.abs((360-gyro.getAngle())% 360);
I've never tried it so I'm not sure if the subtracting 180 part works, but I'd definitely recommend you try it.

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

2 participants