Phidget Spatial Basic 3/3/3 - Compass bearing

Supporting Browser-based Javascript and Node.js
Post Reply
Stella.bilodeau
Fresh meat
Posts: 2
Joined: Thu Oct 25, 2018 9:10 am
Contact:

Phidget Spatial Basic 3/3/3 - Compass bearing

Post 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 :? .
User avatar
mparadis
Site Admin
Posts: 660
Joined: Fri Oct 28, 2011 12:17 pm
Contact:

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

Post by mparadis »

You'll have to calculate bearing manually. See this page in our documentation for more information.
Stella.bilodeau
Fresh meat
Posts: 2
Joined: Thu Oct 25, 2018 9:10 am
Contact:

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

Post 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?
User avatar
mparadis
Site Admin
Posts: 660
Joined: Fri Oct 28, 2011 12:17 pm
Contact:

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

Post 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.
clinton_le_castor
Fresh meat
Posts: 1
Joined: Fri Aug 19, 2022 8:51 am
Contact:

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

Post by clinton_le_castor »

Have you found out how to calculate the Compass Data Pitch Roll Bearing?
I only need this in Python...
User avatar
mparadis
Site Admin
Posts: 660
Joined: Fri Oct 28, 2011 12:17 pm
Contact:

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

Post 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()
Post Reply

Who is online

Users browsing this forum: No registered users and 10 guests