correcting bug in axis mapping of euler angles #123
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes this issue: #96
Scope
When getting euler angles, they will be returned in a different axis mapping now. A more correct mapping.
Limitations
Users using euler angles in existing code will get their x and z angles flipped when they update to later versions. But, this is correcting a bug and likely users have existing code to remap the output from this library, which they could remove.
Tests
I am using this on a raspberry pi, and tested these changes on my master branch in the fork with a similar commit and rotation is as expected (except signs, but I didn't look into that issue).
Details
I think there is a bug in that for euler angles the z rotation is read from the sensor and put into the x part of the output vector. And the x rotation from the sensor gets put into the z part of the vector. There is also some weirdness with signs, but i didn't look into that.
I think this is because the library reads from the registers in this order here, which is heading, roll, pitch. It then writes heading to X, roll to Y, and pitch to Z here.
I've seen conflicting info out there on whether pitch corresponds to x rotation, or pitch corresponds to y rotation. I've tested with this sensor and this breakout board and the data in pitch register corresponds to X rotation in default axis mapping.