public class ModernRoboticsI2cGyro extends I2cDeviceSynchDevice<I2cDeviceSynch> implements GyroSensor, Gyroscope, IntegratingGyroscope, I2cAddrConfig
ModernRoboticsI2cGyro
supports the Modern Robotics integrating gyro.
This sensor contains an L3GD20 MEMS three-axis digital output gyroscope. Internally, the chip is labelled (e.g.) "AGD2 2437 JR4IJ".
Modifier and Type | Class and Description |
---|---|
static class |
ModernRoboticsI2cGyro.Command |
static class |
ModernRoboticsI2cGyro.HeadingMode
ModernRoboticsI2cGyro.HeadingMode can be used to configure the software to return either cartesian or
cardinal headings. |
static class |
ModernRoboticsI2cGyro.MeasurementMode
Deprecated.
This provides little useful utility beyond
isCalibrating() |
static class |
ModernRoboticsI2cGyro.Register |
HardwareDevice.Manufacturer
Modifier and Type | Field and Description |
---|---|
static I2cAddr |
ADDRESS_I2C_DEFAULT |
protected float |
degreesPerSecondPerDigit |
protected float |
degreesPerZAxisTick |
protected ModernRoboticsI2cGyro.HeadingMode |
headingMode |
deviceClient, deviceClientIsOwned, isInitialized
Constructor and Description |
---|
ModernRoboticsI2cGyro(I2cDeviceSynch deviceClient) |
Modifier and Type | Method and Description |
---|---|
void |
calibrate()
Calibrate the gyro.
|
protected float |
degreesZFromIntegratedZ(int integratedZ) |
protected boolean |
doInitialize()
Actually carries out the initialization of the instance.
|
Orientation |
getAngularOrientation(AxesReference reference,
AxesOrder order,
AngleUnit angleUnit)
Returns the absolute orientation of the sensor as a set three angles.
|
java.util.Set<Axis> |
getAngularOrientationAxes()
Returns the axes on which the sensor measures angular orientation.
|
AngularVelocity |
getAngularVelocity(AngleUnit unit)
Returns the angular rotation rate across all the axes measured by the gyro.
|
java.util.Set<Axis> |
getAngularVelocityAxes()
Returns the axes on which the gyroscope measures angular velocity.
|
java.lang.String |
getDeviceName()
Returns a string suitable for display to the user as to the type of device.
|
int |
getHeading()
Return the integrated Z axis as a cartesian heading.
|
ModernRoboticsI2cGyro.HeadingMode |
getHeadingMode() |
I2cAddr |
getI2cAddress()
Returns the I2C address currently in use to communicate with an I2C hardware device
|
int |
getIntegratedZValue() |
HardwareDevice.Manufacturer |
getManufacturer()
Returns an indication of the manufacturer of this device.
|
ModernRoboticsI2cGyro.MeasurementMode |
getMeasurementMode()
Deprecated.
|
double |
getRotationFraction()
Deprecated.
This method has no utility for this gyro.
|
int |
getZAxisOffset() |
int |
getZAxisScalingCoefficient() |
boolean |
isCalibrating()
Is the gyro performing a calibration operation?
|
protected float |
normalize0359(float degrees) |
protected void |
notSupported() |
int |
rawX()
"Gyro Raw Values: The three fields X, Y and Z are the unprocessed values being
obtained from the sensor element.
|
int |
rawY()
Return the gyro's raw Y value.
|
int |
rawZ()
Return the gyro's raw Z value.
|
byte |
read8(ModernRoboticsI2cGyro.Register reg) |
ModernRoboticsI2cGyro.Command |
readCommand() |
short |
readShort(ModernRoboticsI2cGyro.Register reg) |
void |
resetZAxisIntegrator()
Set the integrated Z axis to zero.
|
void |
setHeadingMode(ModernRoboticsI2cGyro.HeadingMode headingMode) |
void |
setI2cAddress(I2cAddr newAddress)
Configures a new I2C address to use
|
protected void |
setOptimalReadWindow() |
void |
setZAxisOffset(short offset) |
void |
setZAxisScalingCoefficient(int zAxisScalingCoefficient) |
java.lang.String |
status()
Status of this sensor, in string form
|
protected int |
truncate(float angle) |
void |
write8(ModernRoboticsI2cGyro.Register reg,
byte value) |
void |
writeCommand(ModernRoboticsI2cGyro.Command command) |
void |
writeShort(ModernRoboticsI2cGyro.Register reg,
short value) |
close, disengage, engage, getConnectionInfo, getDeviceClient, getVersion, initialize, initializeIfNecessary, onModuleStateChange, registerArmingStateCallback, resetDeviceConfigurationForOpMode
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
close, getConnectionInfo, getVersion, resetDeviceConfigurationForOpMode
public static final I2cAddr ADDRESS_I2C_DEFAULT
protected float degreesPerSecondPerDigit
protected ModernRoboticsI2cGyro.HeadingMode headingMode
protected float degreesPerZAxisTick
public ModernRoboticsI2cGyro(I2cDeviceSynch deviceClient)
protected void setOptimalReadWindow()
protected boolean doInitialize()
I2cDeviceSynchDevice
doInitialize
in class I2cDeviceSynchDevice<I2cDeviceSynch>
public HardwareDevice.Manufacturer getManufacturer()
HardwareDevice
getManufacturer
in interface HardwareDevice
public java.lang.String getDeviceName()
HardwareDevice
getDeviceName
in interface HardwareDevice
public byte read8(ModernRoboticsI2cGyro.Register reg)
public void write8(ModernRoboticsI2cGyro.Register reg, byte value)
public short readShort(ModernRoboticsI2cGyro.Register reg)
public void writeShort(ModernRoboticsI2cGyro.Register reg, short value)
public void writeCommand(ModernRoboticsI2cGyro.Command command)
public ModernRoboticsI2cGyro.Command readCommand()
public java.util.Set<Axis> getAngularVelocityAxes()
Gyroscope
Gyroscope.getAngularVelocity(AngleUnit)
.getAngularVelocityAxes
in interface Gyroscope
Gyroscope.getAngularVelocity(AngleUnit)
public java.util.Set<Axis> getAngularOrientationAxes()
OrientationSensor
getAngularOrientationAxes
in interface OrientationSensor
public AngularVelocity getAngularVelocity(AngleUnit unit)
Gyroscope
getAngularVelocity
in interface Gyroscope
unit
- the unit in which the rotation rates are to be returned (the time
dimension is always inverse-seconds).Gyroscope.getAngularVelocityAxes()
public Orientation getAngularOrientation(AxesReference reference, AxesOrder order, AngleUnit angleUnit)
OrientationSensor
getAngularOrientation
in interface OrientationSensor
reference
- the axes reference in which the result will be expressedorder
- the axes order in which the result will be expressedangleUnit
- the angle units in which the result will be expressedOrientation
public void setHeadingMode(ModernRoboticsI2cGyro.HeadingMode headingMode)
public ModernRoboticsI2cGyro.HeadingMode getHeadingMode()
public int rawX()
rawX
in interface GyroSensor
public int rawY()
GyroSensor
rawY
in interface GyroSensor
rawX()
public int rawZ()
GyroSensor
rawZ
in interface GyroSensor
rawX()
public int getZAxisOffset()
public void setZAxisOffset(short offset)
public int getZAxisScalingCoefficient()
public void setZAxisScalingCoefficient(int zAxisScalingCoefficient)
public int getIntegratedZValue()
public int getHeading()
GyroSensor
getHeading
in interface GyroSensor
protected int truncate(float angle)
protected float normalize0359(float degrees)
protected float degreesZFromIntegratedZ(int integratedZ)
public void resetZAxisIntegrator()
GyroSensor
resetZAxisIntegrator
in interface GyroSensor
public java.lang.String status()
GyroSensor
status
in interface GyroSensor
public void calibrate()
GyroSensor
calibrate
in interface GyroSensor
public boolean isCalibrating()
GyroSensor
isCalibrating
in interface GyroSensor
public void setI2cAddress(I2cAddr newAddress)
I2cAddrConfig
setI2cAddress
in interface I2cAddrConfig
newAddress
- the new I2C address to usepublic I2cAddr getI2cAddress()
I2cAddressableDevice
getI2cAddress
in interface I2cAddressableDevice
@Deprecated public double getRotationFraction()
GyroSensor
getRotationFraction
in interface GyroSensor
@Deprecated public ModernRoboticsI2cGyro.MeasurementMode getMeasurementMode()
isCalibrating()
protected void notSupported()