-
Notifications
You must be signed in to change notification settings - Fork 21
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
Fix quaternion mapping. #26
Conversation
Cargo.toml
Outdated
@@ -22,7 +22,7 @@ byteorder = { version = "1", default-features = false } | |||
serde = { version = "1.0", default-features = false, features = ["derive"], optional = true } | |||
mint = "^0.5.4" | |||
bitflags = "1" | |||
num-traits = "0.2.15" | |||
num-traits = { version = "0.2.15", default-features = false} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be better to enable libm
feature too as it will enable f32 and f64 functions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See #27
let x = x as f32 * scale; | ||
let y = y as f32 * scale; | ||
let z = z as f32 * scale; | ||
let w = w as f32 * scale; | ||
|
||
let quat = mint::Quaternion { | ||
v: mint::Vector3 { x, y, z }, | ||
s: w, | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch, one of my interns also pointed this issue
Thanks for taking a look! Not sure what the workflow is but feel free to edit this pr as needed, otherwise after work I can make some changes. |
f5fa3d3
to
39ddabe
Compare
I decided to just let #28 take care of the no default features needed for no_std. |
Awesome! Can't want to try out the fix for the Quaternions! |
I'm using the quaternion output from the sensor with an esp32c6 and I noticed that the order of the data is wrong.
If I'm reading the mint docs correctly, the order should be x, y, z, w if building the Quat from an array. I switched to explicitly constructing the Quat so it's clearer how the fields are mapped.
Tested with hardware and now the sensor is reacting how I would expect.
I also had to disable the default features for the num-traits crate so that it would compile for a no_std environment.