Skip to content

Compass readings when pitch and roll are modified #17

@eah13

Description

@eah13

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.

  • 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

First 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions