com.phidgets
Class SpatialPhidget

java.lang.Object
  extended bycom.phidgets.Phidget
      extended bycom.phidgets.SpatialPhidget

public final class SpatialPhidget
extends Phidget

This class represents a Phidget Spatial. All methods for a PhidgetSpatial are implemented in this class.

The Phidget Spatial may provide up to 3 axes of acceleration data, 3 axes of angular rate data and 3 axes of magnetic field data.

Author:
Phidgets Inc.

Field Summary
 
Fields inherited from class com.phidgets.Phidget
PHIDCLASS_ACCELEROMETER, PHIDCLASS_ADVANCEDSERVO, PHIDCLASS_ANALOG, PHIDCLASS_BRIDGE, PHIDCLASS_ENCODER, PHIDCLASS_FREQUENCYCOUNTER, PHIDCLASS_GPS, PHIDCLASS_INTERFACEKIT, PHIDCLASS_LED, PHIDCLASS_MOTORCONTROL, PHIDCLASS_NOTHING, PHIDCLASS_PHSENSOR, PHIDCLASS_RFID, PHIDCLASS_SERVO, PHIDCLASS_STEPPER, PHIDCLASS_TEMPERATURESENSOR, PHIDCLASS_TEXTLCD, PHIDCLASS_TEXTLED, PHIDCLASS_WEIGHTSENSOR, PHIDGET_LOG_CRITICAL, PHIDGET_LOG_DEBUG, PHIDGET_LOG_ERROR, PHIDGET_LOG_INFO, PHIDGET_LOG_VERBOSE, PHIDGET_LOG_WARNING, PHIDID_ACCELEROMETER_2AXIS, PHIDID_ACCELEROMETER_3AXIS, PHIDID_ADVANCEDSERVO_1MOTOR, PHIDID_ADVANCEDSERVO_8MOTOR, PHIDID_ANALOG_4OUTPUT, PHIDID_BIPOLAR_STEPPER_1MOTOR, PHIDID_BRIDGE_4INPUT, PHIDID_ENCODER_1ENCODER_1INPUT, PHIDID_ENCODER_HS_1ENCODER, PHIDID_ENCODER_HS_4ENCODER_4INPUT, PHIDID_FREQUENCYCOUNTER_2INPUT, PHIDID_GPS, PHIDID_INTERFACEKIT_0_0_4, PHIDID_INTERFACEKIT_0_0_8, PHIDID_INTERFACEKIT_0_16_16, PHIDID_INTERFACEKIT_0_8_8_w_LCD, PHIDID_INTERFACEKIT_2_2_2, PHIDID_INTERFACEKIT_4_8_8, PHIDID_INTERFACEKIT_8_8_8, PHIDID_INTERFACEKIT_8_8_8_w_LCD, PHIDID_IR, PHIDID_LED_64, PHIDID_LED_64_ADV, PHIDID_LINEAR_TOUCH, PHIDID_MOTORCONTROL_1MOTOR, PHIDID_MOTORCONTROL_HC_2MOTOR, PHIDID_MOTORCONTROL_LV_2MOTOR_4INPUT, PHIDID_NOTHING, PHIDID_PHSENSOR, PHIDID_RFID, PHIDID_RFID_2OUTPUT, PHIDID_RFID_2OUTPUT_READ_WRITE, PHIDID_ROTARY_TOUCH, PHIDID_SERVO_1MOTOR, PHIDID_SERVO_1MOTOR_OLD, PHIDID_SERVO_4MOTOR, PHIDID_SERVO_4MOTOR_OLD, PHIDID_SPATIAL_ACCEL_3AXIS, PHIDID_SPATIAL_ACCEL_GYRO_COMPASS, PHIDID_TEMPERATURESENSOR, PHIDID_TEMPERATURESENSOR_4, PHIDID_TEMPERATURESENSOR_IR, PHIDID_TEXTLCD_2x20, PHIDID_TEXTLCD_2x20_w_0_8_8, PHIDID_TEXTLCD_2x20_w_8_8_8, PHIDID_TEXTLCD_ADAPTER, PHIDID_TEXTLED_1x8, PHIDID_TEXTLED_4x8, PHIDID_UNIPOLAR_STEPPER_4MOTOR, PHIDID_WEIGHTSENSOR
 
Constructor Summary
SpatialPhidget()
           
 
Method Summary
 void addSpatialDataListener(SpatialDataListener l)
          Adds a spatial data listener.
 double getAcceleration(int index)
          Returns the acceleration of a particular axis.
 int getAccelerationAxisCount()
          Returns the number of accelerometer axes.
 double getAccelerationMax(int index)
          Returns the maximum acceleration value that this axis will report.
 double getAccelerationMin(int index)
          Returns the minimum acceleration value that this axis will report.
 double getAngularRate(int index)
          Returns the angularRate of a particular axis.
 double getAngularRateMax(int index)
          Returns the maximum angularRate value that this axis will report.
 double getAngularRateMin(int index)
          Returns the minimum angularRate value that this axis will report.
 int getCompassAxisCount()
          Returns the number of compass axes.
 int getDataRate()
          Returns the data rate, in milliseconds.
 int getDataRateMax()
          Returns the maximum data rate, in milliseconds.
 int getDataRateMin()
          Returns the minimum data rate, in milliseconds.
 int getGyroAxisCount()
          Returns the number of gyro axes.
 double getMagneticField(int index)
          Returns the magneticField of a particular axis.
 double getMagneticFieldMax(int index)
          Returns the maximum magneticField value that this axis will report.
 double getMagneticFieldMin(int index)
          Returns the minimum magneticField value that this axis will report.
 void removeSpatialDataListener(SpatialDataListener l)
           
 void resetCompassCorrectionParameters()
          Resets the compass correction factors.
 void setCompassCorrectionParameters(double magField, double offset0, double offset1, double offset2, double gain0, double gain1, double gain2, double T0, double T1, double T2, double T3, double T4, double T5)
          Sets the compass correction factors.
 void setDataRate(int rate)
          Sets the data rate, in milliseconds.
 void zeroGyro()
          Zeroes the gyroscope.
 
Methods inherited from class com.phidgets.Phidget
addAttachListener, addDetachListener, addErrorListener, addServerConnectListener, addServerDisconnectListener, close, disableLogging, enableLogging, equals, getDeviceClass, getDeviceID, getDeviceLabel, getDeviceName, getDeviceType, getDeviceVersion, getLibraryVersion, getSerialNumber, getServerAddress, getServerID, getServerPort, isAttached, isAttachedToServer, log, open, open, open, open, open, openAny, openAny, openAny, openAny, openAny, openLabel, openLabel, openLabel, openLabel, openLabel, removeAttachListener, removeDetachListener, removeErrorListener, removeServerConnectListener, removeServerDisconnectListener, setDeviceLabel, toString, waitForAttachment, waitForAttachment
 
Methods inherited from class java.lang.Object
getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SpatialPhidget

public SpatialPhidget()
               throws PhidgetException
Method Detail

getAccelerationAxisCount

public int getAccelerationAxisCount()
                             throws PhidgetException
Returns the number of accelerometer axes.

Returns:
number of axes of acceleration
Throws:
PhidgetException

getAcceleration

public double getAcceleration(int index)
                       throws PhidgetException
Returns the acceleration of a particular axis.

Parameters:
index - index of the axis
Returns:
acceleration of the selected axis
Throws:
PhidgetException - If this Phidget is not opened and attached, or if the index is out of range. See open for information on determining if a device is attached.

getAccelerationMax

public double getAccelerationMax(int index)
                          throws PhidgetException
Returns the maximum acceleration value that this axis will report.

Returns:
maximum acceleration
Throws:
PhidgetException

getAccelerationMin

public double getAccelerationMin(int index)
                          throws PhidgetException
Returns the minimum acceleration value that this axis will report.

Returns:
minimum acceleration
Throws:
PhidgetException

getGyroAxisCount

public int getGyroAxisCount()
                     throws PhidgetException
Returns the number of gyro axes.

Returns:
number of axes of angularRate
Throws:
PhidgetException

getAngularRate

public double getAngularRate(int index)
                      throws PhidgetException
Returns the angularRate of a particular axis.

Parameters:
index - index of the axis
Returns:
angularRate of the selected axis
Throws:
PhidgetException - If this Phidget is not opened and attached, or if the index is out of range. See open for information on determining if a device is attached.

getAngularRateMax

public double getAngularRateMax(int index)
                         throws PhidgetException
Returns the maximum angularRate value that this axis will report.

Returns:
maximum angularRate
Throws:
PhidgetException

getAngularRateMin

public double getAngularRateMin(int index)
                         throws PhidgetException
Returns the minimum angularRate value that this axis will report.

Returns:
minimum angularRate
Throws:
PhidgetException

getCompassAxisCount

public int getCompassAxisCount()
                        throws PhidgetException
Returns the number of compass axes.

Returns:
number of axes of magneticField
Throws:
PhidgetException

getMagneticField

public double getMagneticField(int index)
                        throws PhidgetException
Returns the magneticField of a particular axis.

Parameters:
index - index of the axis
Returns:
magneticField of the selected axis
Throws:
PhidgetException - If this Phidget is not opened and attached, or if the index is out of range. See open for information on determining if a device is attached.

getMagneticFieldMax

public double getMagneticFieldMax(int index)
                           throws PhidgetException
Returns the maximum magneticField value that this axis will report.

Returns:
maximum magneticField
Throws:
PhidgetException

getMagneticFieldMin

public double getMagneticFieldMin(int index)
                           throws PhidgetException
Returns the minimum magneticField value that this axis will report.

Returns:
minimum magneticField
Throws:
PhidgetException

getDataRate

public int getDataRate()
                throws PhidgetException
Returns the data rate, in milliseconds.

Returns:
data rate
Throws:
PhidgetException - If this Phidget is not opened and attached, or if the index is out of range. See open for information on determining if a device is attached.

setDataRate

public void setDataRate(int rate)
                 throws PhidgetException
Sets the data rate, in milliseconds.

Parameters:
rate - data rate
Throws:
PhidgetException - If this Phidget is not opened and attached, or if the index is out of range. See open for information on determining if a device is attached.

getDataRateMin

public int getDataRateMin()
                   throws PhidgetException
Returns the minimum data rate, in milliseconds.

Returns:
minimum data rate
Throws:
PhidgetException - If this Phidget is not opened and attached, or if the index is out of range. See open for information on determining if a device is attached.

getDataRateMax

public int getDataRateMax()
                   throws PhidgetException
Returns the maximum data rate, in milliseconds.

Returns:
maximum data rate
Throws:
PhidgetException - If this Phidget is not opened and attached, or if the index is out of range. See open for information on determining if a device is attached.

zeroGyro

public void zeroGyro()
              throws PhidgetException
Zeroes the gyroscope. This takes about two seconds and the gyro zxes will report 0 during the process. This should only be called when the board is not moving.

Throws:
PhidgetException - If this Phidget is not opened and attached, or if the index is out of range. See open for information on determining if a device is attached.

setCompassCorrectionParameters

public void setCompassCorrectionParameters(double magField,
                                           double offset0,
                                           double offset1,
                                           double offset2,
                                           double gain0,
                                           double gain1,
                                           double gain2,
                                           double T0,
                                           double T1,
                                           double T2,
                                           double T3,
                                           double T4,
                                           double T5)
                                    throws PhidgetException
Sets the compass correction factors. This can be used to correcting any sensor errors, including hard and soft iron offsets and sensor error factors.

Parameters:
magField - Local magnetic field strength.
offset0 - Axis 0 offset correction.
offset1 - Axis 1 offset correction.
offset2 - Axis 2 offset correction.
gain0 - Axis 0 gain correction.
gain1 - Axis 1 gain correction.
gain2 - Axis 2 gain correction.
T0 - Non-orthogonality correction factor 0.
T1 - Non-orthogonality correction factor 1.
T2 - Non-orthogonality correction factor 2.
T3 - Non-orthogonality correction factor 3.
T4 - Non-orthogonality correction factor 4.
T5 - Non-orthogonality correction factor 5.
Throws:
PhidgetException - If this Phidget is not opened and attached, or if the index is out of range. See open for information on determining if a device is attached.

resetCompassCorrectionParameters

public void resetCompassCorrectionParameters()
                                      throws PhidgetException
Resets the compass correction factors. Magnetic field data will be presented directly as reported by the sensor.

Throws:
PhidgetException - If this Phidget is not opened and attached, or if the index is out of range. See open for information on determining if a device is attached.

addSpatialDataListener

public final void addSpatialDataListener(SpatialDataListener l)
Adds a spatial data listener. The spatial data handler is a method that will be called at a rate of DataRate that has been set for the device. This event contains data for all axes of all sensors.

There is no limit on the number of spatial data handlers that can be registered for a particular Phidget.

Parameters:
l - An implemetation of the SpatialDataListener interface

removeSpatialDataListener

public final void removeSpatialDataListener(SpatialDataListener l)