Page 1 of 1

Phidget Spatial Basic 3/3/3 - Compass bearing

Posted: Thu Oct 25, 2018 9:13 am
by Stella.bilodeau
Hi :D ,

I would like to know how to access the bearing data of the compass in javascript.

I found the acceleration, the three axis of the compass and the magnetic field, but not the bearing of the compass :? .

Re: Phidget Spatial Basic 3/3/3 - Compass bearing

Posted: Thu Oct 25, 2018 9:18 am
by mparadis
You'll have to calculate bearing manually. See this page in our documentation for more information.

Re: Phidget Spatial Basic 3/3/3 - Compass bearing

Posted: Thu Oct 25, 2018 9:23 am
by Stella.bilodeau
mparadis wrote:You'll have to calculate bearing manually. See this page in our documentation for more information.
Would you have an example in javascript?

Re: Phidget Spatial Basic 3/3/3 - Compass bearing

Posted: Thu Oct 25, 2018 9:31 am
by mparadis
This is the only example we have, but it's mostly math so if you understand what's being calculated it should be easy to convert to JavaScript.

Re: Phidget Spatial Basic 3/3/3 - Compass bearing

Posted: Fri Aug 19, 2022 8:52 am
by clinton_le_castor
Have you found out how to calculate the Compass Data Pitch Roll Bearing?
I only need this in Python...

Re: Phidget Spatial Basic 3/3/3 - Compass bearing

Posted: Fri Aug 19, 2022 9:11 am
by mparadis
That post was from 4 years ago, so things have changed quite a bit.

Our phidget22 library now calculates these for you- look up the "eulerAngles" property (in the Spatial channel class) in the API documentation for details:

Code: Select all

from Phidget22.Phidget import *
from Phidget22.Devices.Spatial import *

ch = Spatial()
ch.openWaitForAttachment(1000)

eulerAngles = ch.getEulerAngles()
print("EulerAngles: " + str(eulerAngles))

ch.close()