av8r1
Posts: 26
Joined: Mon Jun 23, 2014 7:04 pm

How does get_orientation actually work?

Sat Sep 26, 2015 2:22 am

I'm working on a Sense Hat powered quadcopter autopilot. Thing is, the documentation for the python library is really sparse. It basically says

Code: Select all

attitude = sense.get_orientation()
generates a dictionary with keys pitch, roll and yaw, so wham! In one line of code you know which way is down.

But this raises a LOT of questions. Is the Yaw axis measured from magnetic North? Does it compare the accelerometer data to the gyro data? In other words, if the Sense Hat accelerates forward, will it read the gyro, realize it hasn't rotated, and correct for the G force?

The API reference (found here) says you can gather raw accelerometer or gyro data as well, and the way it works is to call the config method and turn everything else off. Does it then turn everything else back on, or do I have to do that myself?

Can anyone shed a little light?

scotty101
Posts: 3958
Joined: Fri Jun 08, 2012 6:03 pm

Re: How does get_orientation actually work?

Sat Sep 26, 2015 10:24 am

The SenseHAT software uses RTIMULIB. You can read the source tonsee how it works

https://github.com/richards-tech/RTIMULib

You are correct though, it does combine date from the various sensors to get its result. Its called sensor fusion.
Electronic and Computer Engineer
Pi Interests: Home Automation, IOT, Python and Tkinter

Return to “Astro Pi”