Package ftclib.archive
Class FtcAndroidAccel
java.lang.Object
trclib.sensor.TrcSensor<TrcAccelerometer.DataType>
trclib.sensor.TrcAccelerometer
ftclib.archive.FtcAndroidAccel
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.
-
Nested Class Summary
Nested classes/interfaces inherited from class trclib.sensor.TrcAccelerometer
TrcAccelerometer.DataType
Nested classes/interfaces inherited from class trclib.sensor.TrcSensor
TrcSensor.DataSource<D>, TrcSensor.SensorData<T>
-
Field Summary
FieldsFields inherited from class trclib.sensor.TrcAccelerometer
ACCEL_DOUBLE_INTEGRATE, ACCEL_HAS_X_AXIS, ACCEL_HAS_Y_AXIS, ACCEL_HAS_Z_AXIS, ACCEL_INTEGRATE, instanceName
-
Constructor Summary
ConstructorsConstructorDescriptionFtcAndroidAccel
(String instanceName) Constructor: Creates an instance of the object.FtcAndroidAccel
(String instanceName, TrcFilter[] filters) Constructor: Creates an instance of the object. -
Method Summary
Modifier and TypeMethodDescriptionvoid
This method calibrates the sensor.getRawXData
(TrcAccelerometer.DataType dataType) This method returns the raw data of the specified type for the x-axis.getRawYData
(TrcAccelerometer.DataType dataType) This method returns the raw data of the specified type for the y-axis.getRawZData
(TrcAccelerometer.DataType dataType) This method returns the raw data of the specified type for the z-axis.void
setEnabled
(boolean enabled) This method enables/disables the sensor.void
setSamplingPeriod
(int period) This method sets the sampling period of the Android accelerometer sensor.Methods inherited from class trclib.sensor.TrcAccelerometer
getRawData, getXAcceleration, getXDistance, getXVelocity, getYAcceleration, getYDistance, getYVelocity, getZAcceleration, getZDistance, getZVelocity, printElapsedTime, resetXIntegrator, resetYIntegrator, resetZIntegrator, setElapsedTimerEnabled, setXInverted, setXScale, setYInverted, setYScale, setZInverted, setZScale, toString
Methods inherited from class trclib.sensor.TrcSensor
calibrate, calibrate, getNumAxes, getProcessedData, isCalibrating, setInverted, setScale, setScaleAndOffset
-
Field Details
-
sensor
-
samplingPeriod
private int samplingPeriod
-
-
Constructor Details
-
FtcAndroidAccel
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
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 classTrcAccelerometer
- 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
This method returns the raw data of the specified type for the x-axis.- Specified by:
getRawXData
in classTrcAccelerometer
- Parameters:
dataType
- specifies the data type.- Returns:
- raw data of the specified type for the x-axis.
-
getRawYData
This method returns the raw data of the specified type for the y-axis.- Specified by:
getRawYData
in classTrcAccelerometer
- Parameters:
dataType
- specifies the data type.- Returns:
- raw data of the specified type for the y-axis.
-
getRawZData
This method returns the raw data of the specified type for the z-axis.- Specified by:
getRawZData
in classTrcAccelerometer
- Parameters:
dataType
- specifies the data type.- Returns:
- raw data of the specified type for the z-axis.
-