lejos.nxt.addon
Class DIMUGyro

java.lang.Object
  extended by lejos.nxt.I2CSensor
      extended by lejos.nxt.addon.DIMUGyro
All Implemented Interfaces:
SensorConstants

public class DIMUGyro
extends I2CSensor

This class provides access to the gyro of Dexter Industries IMU sensor. Rate data can be fetched using the fetchAllRate method. Temperature data can be fetched using the fetchTemperature method.

Orientation of Axes: Assuming the flat side of the dIMU sensor is facing you and the sensor port is at the bottom, the axes are as follows: X axis runs from top to bottom, Y axis runs left to right, Z axis comes directly out the front of the sensor board.

Version:
1.0
Author:
Aswin Bouwmeester

Nested Class Summary
static class DIMUGyro.Axis
          Axis units supported by the sensor.
static class DIMUGyro.Range
          Dynamic ranges supported by the sensor
static class DIMUGyro.RateUnits
          Rotation units supported by the sensor
static class DIMUGyro.SampleRate
          Internal sample rates supported by the sensor
static class DIMUGyro.TemperatureUnits
          Temperature units supported by the sensor
 
Field Summary
protected  boolean[] dynamicOffset
           
protected  float I
           
protected  float[] offset
           
protected  DIMUGyro.Range range
           
protected  DIMUGyro.RateUnits rateUnit
           
protected  DIMUGyro.SampleRate sampleRate
           
protected  DIMUGyro.TemperatureUnits temperatureUnit
           
 
Fields inherited from class lejos.nxt.I2CSensor
DEFAULT_I2C_ADDRESS, port, REG_PRODUCT_ID, REG_VENDOR_ID, REG_VERSION
 
Fields inherited from interface lejos.nxt.SensorConstants
BLACK, BLANK_INDEX, BLUE, BLUE_INDEX, GREEN, GREEN_INDEX, MAX_AD_RAW, MAX_TYPE, MIN_TYPE, MODE_ANGLESTEP, MODE_BOOLEAN, MODE_CELSIUS, MODE_FARENHEIT, MODE_PCTFULLSCALE, MODE_PERIODCOUNTER, MODE_RAW, MODE_TRANSITIONCNT, RED, RED_INDEX, TYPE_ANGLE, TYPE_COLORBLUE, TYPE_COLORFULL, TYPE_COLORGREEN, TYPE_COLORNONE, TYPE_COLORRED, TYPE_CUSTOM, TYPE_HISPEED, TYPE_LIGHT_ACTIVE, TYPE_LIGHT_INACTIVE, TYPE_LOWSPEED, TYPE_LOWSPEED_9V, TYPE_NO_SENSOR, TYPE_REFLECTION, TYPE_SOUND_DB, TYPE_SOUND_DBA, TYPE_SWITCH, TYPE_TEMPERATURE, WHITE, YELLOW
 
Constructor Summary
DIMUGyro(I2CPort port)
           
 
Method Summary
 void calculateOffset()
          Calibrates the sensor
 void fetchAllRate(float[] ret)
           
 void fetchAllRate(float[] ret, DIMUGyro.RateUnits unit)
           
 float fetchTemperature()
          Temperature is not calibrated.
 Gyroscope getAxis(DIMUGyro.Axis axis)
          This method returns an instance of one of the three axes (X, Y, or Z) that the dIMU can supply.
 boolean[] getDynamicOffset()
           
 float getOffsetCorrectionSpeed()
           
 java.lang.String getProductID()
          Read the sensor's product identifier.
 DIMUGyro.Range getRange()
           
 DIMUGyro.RateUnits getRateUnit()
           
 void getRawRate(int[] ret)
           
 DIMUGyro.SampleRate getSampleRate()
           
 DIMUGyro.TemperatureUnits getTemperatureUnit()
           
 java.lang.String getVendorID()
          Read the sensor's vendor identifier.
 java.lang.String getVersion()
          Read the sensor's version string.
protected  boolean isDataOverrun()
           
 boolean isNewDataAvailable()
          Returns true if new data is available from the sensor
 void setDynamicOffset(boolean[] set)
          Enables or disables the dynamic offset correction mechanism of the sensor Dynamic offset correction assumes that in the long run the sensor keeps its orientation.
 void setOffsetCorrectionSpeed(float i)
           
 void setRange(DIMUGyro.Range range)
           
 void setRateUnit(DIMUGyro.RateUnits unit)
           
 void setSampleRate(DIMUGyro.SampleRate rate)
           
 void setTemperatureUnit(DIMUGyro.TemperatureUnits unit)
           
 
Methods inherited from class lejos.nxt.I2CSensor
fetchString, getAddress, getData, getData, getData, getId, sendData, sendData, sendData, setAddress
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

I

protected float I

dynamicOffset

protected boolean[] dynamicOffset

offset

protected float[] offset

range

protected DIMUGyro.Range range

sampleRate

protected DIMUGyro.SampleRate sampleRate

temperatureUnit

protected DIMUGyro.TemperatureUnits temperatureUnit

rateUnit

protected DIMUGyro.RateUnits rateUnit
Constructor Detail

DIMUGyro

public DIMUGyro(I2CPort port)
Method Detail

getAxis

public Gyroscope getAxis(DIMUGyro.Axis axis)
This method returns an instance of one of the three axes (X, Y, or Z) that the dIMU can supply.

Parameters:
axis - The axis (X, Y or Z) to retrieve Gyroscope object
Returns:
A Gyroscope object representing the axis you requested.

calculateOffset

public void calculateOffset()
Calibrates the sensor


fetchAllRate

public void fetchAllRate(float[] ret)

fetchAllRate

public void fetchAllRate(float[] ret,
                         DIMUGyro.RateUnits unit)

fetchTemperature

public float fetchTemperature()
Temperature is not calibrated.

Returns:
temperature in degrees Celsius

getDynamicOffset

public boolean[] getDynamicOffset()

getOffsetCorrectionSpeed

public float getOffsetCorrectionSpeed()

getProductID

public java.lang.String getProductID()
Description copied from class: I2CSensor
Read the sensor's product identifier. This method reads up to 8 bytes and returns the characters before the zero termination byte. Examples: "Sonar", ...

Overrides:
getProductID in class I2CSensor
Returns:
product identifier

getRange

public final DIMUGyro.Range getRange()

getRateUnit

public DIMUGyro.RateUnits getRateUnit()

getRawRate

public void getRawRate(int[] ret)

getSampleRate

public final DIMUGyro.SampleRate getSampleRate()

getVendorID

public java.lang.String getVendorID()
Description copied from class: I2CSensor
Read the sensor's vendor identifier. This method reads up to 8 bytes and returns the characters before the zero termination byte. Examples: "LEGO", "HiTechnc", ...

Overrides:
getVendorID in class I2CSensor
Returns:
vendor identifier

getTemperatureUnit

public DIMUGyro.TemperatureUnits getTemperatureUnit()

getVersion

public java.lang.String getVersion()
Description copied from class: I2CSensor
Read the sensor's version string. This method reads up to 8 bytes and returns the characters before the zero termination byte. Examples: "V1.0", ...

Overrides:
getVersion in class I2CSensor
Returns:
version number

isDataOverrun

protected boolean isDataOverrun()

isNewDataAvailable

public boolean isNewDataAvailable()
Returns true if new data is available from the sensor


setDynamicOffset

public void setDynamicOffset(boolean[] set)
Enables or disables the dynamic offset correction mechanism of the sensor Dynamic offset correction assumes that in the long run the sensor keeps its orientation. It updates the offset using a I-controller. The update speed (I-factor) is controlled by setOffsetCorrectionSpeed().

It is advised not to use dynamic offset for this sensor.

Parameters:
set - an 3-element array of booleans. True enables Dynamic Offset Correction, false disables it. Order of elements is X, Y, Z.

setOffsetCorrectionSpeed

public void setOffsetCorrectionSpeed(float i)

setRange

public void setRange(DIMUGyro.Range range)

setRateUnit

public void setRateUnit(DIMUGyro.RateUnits unit)

setSampleRate

public void setSampleRate(DIMUGyro.SampleRate rate)

setTemperatureUnit

public void setTemperatureUnit(DIMUGyro.TemperatureUnits unit)