You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, the compass reading simply returns the yaw value (as in the sense_hat module, but see below for why this won't work for emulators). This can lead to incorrect values any time roll and pitch aren't set to zero.
set roll and pitch to 180
get_compass() should return 180 since the sense hat is pointing South, yet the compass still returns the yaw value, 0
I believe the root of this that the sense_hat module reads the yaw from the magnetometer only, and in the underlying RTIMU library this solution uses quaternions to normalize the magnetometer's yaw based on the device's pose, producing the correct output for all poses. You don't use quaternions internally (I think - and neither do we), so might be a tough fix.
I believe there is a non-quaternion calculation that could achieve the same effect of normalizing the magnetometer's readings but it's beyond my mathematical skills to derive it. If I've diagnosed this correctly and you can determine how to correctly read the compass when pitch and roll are set, we'd definitely piggy back on your code to fix this in our emulator. Likewise, if we can produce a solution I'll leave a note here.
The text was updated successfully, but these errors were encountered:
I found a formula that seems to correctly derive the heading, given the accelerometer's tilt. We're probably going with this as a fix as it seems to produce the expected values. The math was totally lifted though :)
Edit: that math wasn't quite right. After much banging of the head against trigonometric walls, this should be the correct code: trinketapp/skulpt@ad8c30b
So you needed to transform the raw magnetometer values into the proper plane, I guess? I'm kinda doing the same algorithms in my thesis project so the sense-hat-emulator is a interesting application for me. really cool !
Thanks for a great project!
Currently, the compass reading simply returns the yaw value (as in the
sense_hat
module, but see below for why this won't work for emulators). This can lead to incorrect values any time roll and pitch aren't set to zero.get_compass()
should return 180 since the sense hat is pointing South, yet the compass still returns the yaw value, 0First noted in trinketapp/3D-testing#11
I believe the root of this that the
sense_hat
module reads the yaw from the magnetometer only, and in the underlying RTIMU library this solution uses quaternions to normalize the magnetometer's yaw based on the device's pose, producing the correct output for all poses. You don't use quaternions internally (I think - and neither do we), so might be a tough fix.I believe there is a non-quaternion calculation that could achieve the same effect of normalizing the magnetometer's readings but it's beyond my mathematical skills to derive it. If I've diagnosed this correctly and you can determine how to correctly read the compass when pitch and roll are set, we'd definitely piggy back on your code to fix this in our emulator. Likewise, if we can produce a solution I'll leave a note here.
The text was updated successfully, but these errors were encountered: