FAPSI
Posts: 3
Joined: Tue Aug 20, 2013 1:56 pm

Compass conflicts with Pitch and Roll - Reading of Zero

Sun Oct 09, 2016 2:42 pm

Hi,

using the Sense Hat to log all the data that is coming from him in a loop, I just experienced that reading the compass
north = sense.get_compass()
results in a reading of 0 for pitch an roll afterwards:
orientation = sense.get_orientation()
pitch = orientation['pitch']
roll = orientation['roll']

If the compass is read out after pitch and roll, the second and all further readings of pitch and roll are exactly the same as for the first reading.
Has anyone experienced this before? It seems there is some "reset" missing in the get_orientation function.

User avatar
Davespice
Forum Moderator
Forum Moderator
Posts: 1662
Joined: Fri Oct 14, 2011 8:06 pm
Location: The Netherlands
Contact: Twitter

Re: Compass conflicts with Pitch and Roll - Reading of Zero

Wed Oct 12, 2016 10:06 am

So the get_compass function makes a call to set_imu_config to disable everything but the compass.
In your code you would need to do something like this to compensate

Code: Select all

north = sense.get_compass()
sense.set_imu_config(True, True, True)
orientation = sense.get_orientation()
pitch = orientation['pitch']
roll = orientation['roll']
I hope this helps. See also this closed issue: https://github.com/RPi-Distro/python-se ... /issues/46

Return to “Astro Pi”