Class 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.
  • Field Details

  • 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

      public FtcMRI2cGyro(String instanceName, int i2cAddress, boolean addressIs7Bit)
      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

      public FtcMRI2cGyro(String instanceName)
      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

      public TrcSensor.SensorData<Double> getHeading()
      This method returns the heading data.
      Returns:
      heading data in the range of 0 and 359 inclusive.
    • getIntegratedZ

      public TrcSensor.SensorData<Double> getIntegratedZ()
      This method returns the integrated Z value.
      Returns:
      integrated Z value.
    • getRawX

      public TrcSensor.SensorData<Double> getRawX()
      This method returns the raw turn rate of the X-axis.
      Returns:
      raw X turn rate.
    • getRawY

      public TrcSensor.SensorData<Double> getRawY()
      This method returns the raw turn rate of the Y-axis.
      Returns:
      raw Y turn rate.
    • getRawZ

      public TrcSensor.SensorData<Double> getRawZ()
      This method returns the raw turn rate of the Z-axis.
      Returns:
      raw Z turn rate.
    • getZOffset

      public TrcSensor.SensorData<Double> getZOffset()
      This method returns the offset of the Z-axis.
      Returns:
      Z offset.
    • getZScaling

      public TrcSensor.SensorData<Double> getZScaling()
      This method returns the scaling coefficient of the Z-axis.
      Returns:
      Z scaling coefficient.
    • getRawData

      public TrcSensor.SensorData<Double> getRawData(int index, FtcMRI2cGyro.DataType dataType)
      This method returns the sensor data of the specified index.
      Specified by:
      getRawData in interface TrcSensor.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:
      setXInverted in interface TrcGyro.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:
      setYInverted in interface TrcGyro.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:
      setZInverted in interface TrcGyro.GyroData
      Parameters:
      inverted - specifies true to invert z-axis, false otherwise.
    • getXRotationRate

      public TrcSensor.SensorData<Double> getXRotationRate()
      This method returns the rotation rate on the x-axis.
      Specified by:
      getXRotationRate in interface TrcGyro.GyroData
      Returns:
      X rotation rate.
    • getYRotationRate

      public TrcSensor.SensorData<Double> getYRotationRate()
      This method returns the rotation rate on the y-axis.
      Specified by:
      getYRotationRate in interface TrcGyro.GyroData
      Returns:
      Y rotation rate.
    • getZRotationRate

      public TrcSensor.SensorData<Double> getZRotationRate()
      This method returns the rotation rate on the z-axis.
      Specified by:
      getZRotationRate in interface TrcGyro.GyroData
      Returns:
      Z rotation rate.
    • getXHeading

      public TrcSensor.SensorData<Double> 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:
      getXHeading in interface TrcGyro.GyroData
      Returns:
      X heading.
    • getYHeading

      public TrcSensor.SensorData<Double> 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:
      getYHeading in interface TrcGyro.GyroData
      Returns:
      Y heading.
    • getZHeading

      public TrcSensor.SensorData<Double> 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:
      getZHeading in interface TrcGyro.GyroData
      Returns:
      Z heading.
    • resetXIntegrator

      public void resetXIntegrator()
      This method resets the integrator on the x-axis.
      Specified by:
      resetXIntegrator in interface TrcGyro.GyroData
    • resetYIntegrator

      public void resetYIntegrator()
      This method resets the integrator on the y-axis.
      Specified by:
      resetYIntegrator in interface TrcGyro.GyroData
    • resetZIntegrator

      public void resetZIntegrator()
      This method resets the integrator on the z-axis.
      Specified by:
      resetZIntegrator in interface TrcGyro.GyroData