Skip to content

Latest commit

 

History

History
96 lines (77 loc) · 5.21 KB

Spatial.md

File metadata and controls

96 lines (77 loc) · 5.21 KB

#Phidget Spatial The PhidgetSpatial library makes for intuitive and lightning fast development without any compromise. All sensors on the Phidget Spatial board should be primed for accurate use, here are the acceleration, gyroscopic, and magnetic field primer guides. For a quick start into your Spatial project see this basic PhidgetSpatial example.

##Methods

Method call Parameters Description
connect phidget.params object Connects the Phidget Spatial
quit N/A This method requests a disconnect from the Phidget board. The disconnected event will be dispatched when the connection has been successfully disconnected.
whenReady function This executes a function when the PhidgetSpatial is ready to be used. If you set intervals on this event, you MUST clear them on the detach event! Otherwise, you could set multiple instances of the same interval if a phidget is detached and re attached
observeGyro change handler function Used for asynchronously observing the changes to the PhidgetSpatial board's gyroscopic sensors.
unobserveGyro change handler function Stops observing from the specified observeGyro's change handler function.
observeAcceleration change handler function Used for asynchronously observing the changes to the PhidgetSpatial board's acceleration axes.
unobserveAcceleration change handler function Stops observing from the specified observeAcceleration's change handler function.
observeMagneticField change handler function Used for asynchronously observing the changes to the PhidgetSpatial board's magnetic field sensors.
unobserveMagneticField change handler function Stops observing from the specified observeMagneticField's change handler function.
zeroGyro N/A Re-zeroes the gyroscope.
setCompassCorrectionParameters magfield, offset0, offset1, offset2, gain0, gain1, gain2, T0, T1, T2, T3, T4, T5 This function adjusts the parameters of the compass.
resetCompassCorrectionParameters N/A Resets the Compass Correction Parameters to default values:(1,0,0,0,1,1,1,0,0,0,0,0,0)

##Data

Key Data Type Writable Description
type string no 'PhidgetSpatial'
dataRateMax number no Maximum data rate in samples per second
dataRateMin number no Minimum data rate in samples per second
dataRate number yes The number of times data is acquired per second
accelerationMin number no Minimum acceleration in g
accelerationMax number no Maximum acceleration in g
accelerationAxisCount number no Number of acceleration sensors
acceleration array no three axes of acceleration in g
angularRateMax number no Minimum rotational speed in degrees per second
angularRateMin number no Maximum rotational speed in degrees per second
gyroAxisCount number no Number of gyroscopic sensors
gyro array no three axes of rotational speed in degrees per second
magneticFieldMax number no Maximum magnetic field in Gauss
magneticFieldMin number no Minimum magnetic field in Gauss
compassAxisCount number no Number of magnetic field sensors
magneticField array no three axes of magnetic field in Gauss

##Getting Started

Initializing Phidgets Spatial Devices can be very easy, here is a basic example to help you get started.

var Phidget = require('phidgetapi').Spatial;

var spatial=new Phidget;
spatial.observeGyro(gyro);
spatial.observeAcceleration(accel);
spatial.observeMagneticField(mag);

function gyro(changes){
    for(var i in changes){
        var change=changes[i];
        //see specific info about each change
        //console.log(change);
    }

    //see updated Spatial data after all changes
    //console.log(changes[changes.length-1].object);

    //Or just the info you care about
    console.log('gyro : ',spatial.gyro);
}

function accel(changes){
    for(var i in changes){
        var change=changes[i];
        //see specific info about each change
        //console.log(change);
    }

    //see updated Spatial data after all changes
    //console.log(changes[changes.length-1].object);

    //Or just the info you care about
    console.log('accel : ',spatial.acceleration);
}

function mag(changes){
    for(var i in changes){
        var change=changes[i];
        //see specific info about each change
        //console.log(change);
    }

    //see updated Spatial data after all changes
    //console.log(changes[changes.length-1].object);

    //Or just the info you care about
    console.log('magnetic field : ',spatial.magneticField);
}

spatial.connect();