Class FtcAndroidAccel


public class FtcAndroidAccel extends TrcAccelerometer
This class implements the Android accelerometer extending TrcAccelerometer. It provides implementation of the abstract methods in TrcAccelerometer. It supports 3 axes: x, y and z. It provides acceleration data for all 3 axes. However, it doesn't provide any velocity or distance data.
  • Field Details

    • sensor

      private final FtcAndroidSensor sensor
    • samplingPeriod

      private int samplingPeriod
  • Constructor Details

    • FtcAndroidAccel

      public FtcAndroidAccel(String instanceName, TrcFilter[] filters)
      Constructor: Creates an instance of the object.
      Parameters:
      instanceName - specifies the instance name.
      filters - specifies an array of filters to use for filtering sensor noise, one for each axis. Since we have 3 axes, the array should have 3 elements. If no filters are used, it can be set to null.
    • FtcAndroidAccel

      public FtcAndroidAccel(String instanceName)
      Constructor: Creates an instance of the object.
      Parameters:
      instanceName - specifies the instance name.
  • Method Details

    • setSamplingPeriod

      public void setSamplingPeriod(int period)
      This method sets the sampling period of the Android accelerometer sensor.
      Parameters:
      period - specifies the period with SensorManager.SENSOR_DELAY_* constants, or the number of microseconds.
    • setEnabled

      public void setEnabled(boolean enabled)
      This method enables/disables the sensor.
      Overrides:
      setEnabled in class TrcAccelerometer
      Parameters:
      enabled - specifies true if enabling, false otherwise.
    • calibrate

      public void calibrate()
      This method calibrates the sensor. If the sensor is not enabled, it must enable it first before starting calibration. It will disable the sensor if it was disabled before calibration.
    • getRawXData

      public TrcSensor.SensorData<Double> getRawXData(TrcAccelerometer.DataType dataType)
      This method returns the raw data of the specified type for the x-axis.
      Specified by:
      getRawXData in class TrcAccelerometer
      Parameters:
      dataType - specifies the data type.
      Returns:
      raw data of the specified type for the x-axis.
    • getRawYData

      public TrcSensor.SensorData<Double> getRawYData(TrcAccelerometer.DataType dataType)
      This method returns the raw data of the specified type for the y-axis.
      Specified by:
      getRawYData in class TrcAccelerometer
      Parameters:
      dataType - specifies the data type.
      Returns:
      raw data of the specified type for the y-axis.
    • getRawZData

      public TrcSensor.SensorData<Double> getRawZData(TrcAccelerometer.DataType dataType)
      This method returns the raw data of the specified type for the z-axis.
      Specified by:
      getRawZData in class TrcAccelerometer
      Parameters:
      dataType - specifies the data type.
      Returns:
      raw data of the specified type for the z-axis.