Package ftclib.archive
Class FtcMRI2cGyro
java.lang.Object
trclib.robotcore.TrcSerialBusDevice
ftclib.robotcore.FtcI2cDevice
ftclib.archive.FtcMRI2cDevice
ftclib.archive.FtcMRI2cGyro
- All Implemented Interfaces:
TrcGyro.GyroData,TrcSensor.DataSource<FtcMRI2cGyro.DataType>
public class FtcMRI2cGyro
extends FtcMRI2cDevice
implements TrcGyro.GyroData, TrcSensor.DataSource<FtcMRI2cGyro.DataType>
This class implements the Modern Robotics Gyro extending FtcMRI2cDevice that implements the common features of
all Modern Robotics I2C devices.
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from class trclib.robotcore.TrcSerialBusDevice
TrcSerialBusDevice.Request -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate booleanprivate static final byteprivate static final byteprivate static final byteprivate static final bytestatic final intprivate static final intprivate static final intprivate static final intprivate static final intprivate static final intprivate static final intprivate static final intprivate static final intprivate static final intprivate static final intprivate static final intprivate static final intprivate static final intprivate static final intprivate static final intprivate static final intprivate static final intprivate intprivate intprivate intFields inherited from class ftclib.archive.FtcMRI2cDevice
MANUFACTURER_CODE, REG_COMMAND, REG_FIRMWARE_REVISION, REG_ID_CODE, REG_MANUFACTURER_CODE, REG_SET_I2C_ADDRESSFields inherited from class ftclib.robotcore.FtcI2cDevice
deviceSynchFields inherited from class trclib.robotcore.TrcSerialBusDevice
instanceName, tracer -
Constructor Summary
ConstructorsConstructorDescriptionFtcMRI2cGyro(com.qualcomm.robotcore.hardware.HardwareMap hardwareMap, String instanceName, int i2cAddress, boolean addressIs7Bit) Constructor: Creates an instance of the object.FtcMRI2cGyro(String instanceName) Constructor: Creates an instance of the object.FtcMRI2cGyro(String instanceName, int i2cAddress, boolean addressIs7Bit) Constructor: Creates an instance of the object. -
Method Summary
Modifier and TypeMethodDescriptionvoidThis method initiates the gyro calibration.This method returns the heading data.This method returns the integrated Z value.getRawData(int index, FtcMRI2cGyro.DataType dataType) This method returns the sensor data of the specified index.getRawX()This method returns the raw turn rate of the X-axis.getRawY()This method returns the raw turn rate of the Y-axis.getRawZ()This method returns the raw turn rate of the Z-axis.This method returns the heading of the x-axis.This method returns the rotation rate on the x-axis.This method returns the heading of the y-axis.This method returns the rotation rate on the y-axis.This method returns the heading of the z-axis.This method returns the offset of the Z-axis.This method returns the rotation rate on the z-axis.This method returns the scaling coefficient of the Z-axis.booleanThis method check if the calibration is still in progress.voidThis method resets the integrator on the x-axis.voidThis method resets the integrator on the y-axis.voidThis method resets the integrator on the z-axis.voidsetXInverted(boolean inverted) This method inverts the x-axis.voidsetYInverted(boolean inverted) This method inverts the y-axis.voidsetZInverted(boolean inverted) This method inverts the z-axis.Methods inherited from class ftclib.archive.FtcMRI2cDevice
changeI2cAddress, changeI2cAddress, getFirmwareRevision, getIdCode, getManufacturerCodeMethods inherited from class ftclib.robotcore.FtcI2cDevice
readData, writeDataMethods inherited from class trclib.robotcore.TrcSerialBusDevice
asyncRead, asyncRead, asyncRead, asyncRead, asyncRead, asyncWrite, asyncWrite, asyncWrite, isEnabled, preemptiveWrite, sendByteCommand, sendWordCommand, setEnabled, syncRead, syncRead, syncWrite, syncWrite, toString
-
Field Details
-
DEF_I2CADDRESS
public static final int DEF_I2CADDRESS- See Also:
-
REG_HEADING_LSB
private static final int REG_HEADING_LSB- See Also:
-
REG_HEADING_MSB
private static final int REG_HEADING_MSB- See Also:
-
REG_INTEGRATED_Z_LSB
private static final int REG_INTEGRATED_Z_LSB- See Also:
-
REG_INTEGRATED_Z_MSB
private static final int REG_INTEGRATED_Z_MSB- See Also:
-
REG_RAW_X_LSB
private static final int REG_RAW_X_LSB- See Also:
-
REG_RAW_X_MSB
private static final int REG_RAW_X_MSB- See Also:
-
REG_RAW_Y_LSB
private static final int REG_RAW_Y_LSB- See Also:
-
REG_RAW_Y_MSB
private static final int REG_RAW_Y_MSB- See Also:
-
REG_RAW_Z_LSB
private static final int REG_RAW_Z_LSB- See Also:
-
REG_RAW_Z_MSB
private static final int REG_RAW_Z_MSB- See Also:
-
REG_Z_OFFSET_LSB
private static final int REG_Z_OFFSET_LSB- See Also:
-
REG_Z_OFFSET_MSB
private static final int REG_Z_OFFSET_MSB- See Also:
-
REG_Z_SCALING_LSB
private static final int REG_Z_SCALING_LSB- See Also:
-
REG_Z_SCALING_MSB
private static final int REG_Z_SCALING_MSB- See Also:
-
READ_START
private static final int READ_START- See Also:
-
READ_END
private static final int READ_END- See Also:
-
READ_LENGTH
private static final int READ_LENGTH- See Also:
-
CMD_MEASUREMENT_MODE
private static final byte CMD_MEASUREMENT_MODE- See Also:
-
CMD_RESET_OFFSET_CAL
private static final byte CMD_RESET_OFFSET_CAL- See Also:
-
CMD_RESET_Z_INTEGRATOR
private static final byte CMD_RESET_Z_INTEGRATOR- See Also:
-
CMD_WRITE_EEPROM_DATA
private static final byte CMD_WRITE_EEPROM_DATA- See Also:
-
calibrating
private boolean calibrating -
xSign
private int xSign -
ySign
private int ySign -
zSign
private int zSign
-
-
Constructor Details
-
FtcMRI2cGyro
public FtcMRI2cGyro(com.qualcomm.robotcore.hardware.HardwareMap hardwareMap, String instanceName, int i2cAddress, boolean addressIs7Bit) Constructor: Creates an instance of the object.- Parameters:
hardwareMap- specifies the global hardware map.instanceName- specifies the instance name.i2cAddress- specifies the I2C address of the device.addressIs7Bit- specifies true if the I2C address is a 7-bit address, false if it is 8-bit.
-
FtcMRI2cGyro
Constructor: Creates an instance of the object.- Parameters:
instanceName- specifies the instance name.i2cAddress- specifies the I2C address of the device.addressIs7Bit- specifies true if the I2C address is a 7-bit address, false if it is 8-bit.
-
FtcMRI2cGyro
Constructor: Creates an instance of the object.- Parameters:
instanceName- specifies the instance name.
-
-
Method Details
-
calibrate
public void calibrate()This method initiates the gyro calibration. The process may take a little time to complete. -
isCalibrating
public boolean isCalibrating()This method check if the calibration is still in progress.- Returns:
- true if calibration is still in progress, false otherwise.
-
getHeading
This method returns the heading data.- Returns:
- heading data in the range of 0 and 359 inclusive.
-
getIntegratedZ
This method returns the integrated Z value.- Returns:
- integrated Z value.
-
getRawX
This method returns the raw turn rate of the X-axis.- Returns:
- raw X turn rate.
-
getRawY
This method returns the raw turn rate of the Y-axis.- Returns:
- raw Y turn rate.
-
getRawZ
This method returns the raw turn rate of the Z-axis.- Returns:
- raw Z turn rate.
-
getZOffset
This method returns the offset of the Z-axis.- Returns:
- Z offset.
-
getZScaling
This method returns the scaling coefficient of the Z-axis.- Returns:
- Z scaling coefficient.
-
getRawData
This method returns the sensor data of the specified index.- Specified by:
getRawDatain interfaceTrcSensor.DataSource<FtcMRI2cGyro.DataType>- Parameters:
index- specifies the data index.dataType- specifies the data type.- Returns:
- sensor data of the specified index and type.
-
setXInverted
public void setXInverted(boolean inverted) This method inverts the x-axis. This is useful if the orientation of the gyro x-axis is such that the data goes the wrong direction.- Specified by:
setXInvertedin interfaceTrcGyro.GyroData- Parameters:
inverted- specifies true to invert x-axis, false otherwise.
-
setYInverted
public void setYInverted(boolean inverted) This method inverts the y-axis. This is useful if the orientation of the gyro y-axis is such that the data goes the wrong direction.- Specified by:
setYInvertedin interfaceTrcGyro.GyroData- Parameters:
inverted- specifies true to invert y-axis, false otherwise.
-
setZInverted
public void setZInverted(boolean inverted) This method inverts the z-axis. This is useful if the orientation of the gyro z-axis is such that the data goes the wrong direction.- Specified by:
setZInvertedin interfaceTrcGyro.GyroData- Parameters:
inverted- specifies true to invert z-axis, false otherwise.
-
getXRotationRate
This method returns the rotation rate on the x-axis.- Specified by:
getXRotationRatein interfaceTrcGyro.GyroData- Returns:
- X rotation rate.
-
getYRotationRate
This method returns the rotation rate on the y-axis.- Specified by:
getYRotationRatein interfaceTrcGyro.GyroData- Returns:
- Y rotation rate.
-
getZRotationRate
This method returns the rotation rate on the z-axis.- Specified by:
getZRotationRatein interfaceTrcGyro.GyroData- Returns:
- Z rotation rate.
-
getXHeading
This method returns the heading of the x-axis. If there is an integrator, we call the integrator to get the heading. Else if we have an unwrapper, we call the unwrapper to get the heading else we call the platform dependent gyro to get the raw heading value.- Specified by:
getXHeadingin interfaceTrcGyro.GyroData- Returns:
- X heading.
-
getYHeading
This method returns the heading of the y-axis. If there is an integrator, we call the integrator to get the heading. Else if we have an unwrapper, we call the unwrapper to get the heading else we call the platform dependent gyro to get the raw heading value.- Specified by:
getYHeadingin interfaceTrcGyro.GyroData- Returns:
- Y heading.
-
getZHeading
This method returns the heading of the z-axis. If there is an integrator, we call the integrator to get the heading. Else if we have an unwrapper, we call the unwrapper to get the heading else we call the platform dependent gyro to get the raw heading value.- Specified by:
getZHeadingin interfaceTrcGyro.GyroData- Returns:
- Z heading.
-
resetXIntegrator
public void resetXIntegrator()This method resets the integrator on the x-axis.- Specified by:
resetXIntegratorin interfaceTrcGyro.GyroData
-
resetYIntegrator
public void resetYIntegrator()This method resets the integrator on the y-axis.- Specified by:
resetYIntegratorin interfaceTrcGyro.GyroData
-
resetZIntegrator
public void resetZIntegrator()This method resets the integrator on the z-axis.- Specified by:
resetZIntegratorin interfaceTrcGyro.GyroData
-