Package trclib.sensor
Class TrcAnalogInput
- Direct Known Subclasses:
FtcAnalogInput
,TrcAnalogSensor
This class implements a platform independent AnalogInput. Typically, this class is extended by a platform dependent
sensor class that produces value data. The sensor doesn't have to be connected to the AnalogInput port. It could be
connected to an I2C port as long as it produces a value data. The platform dependent sensor class must implement
the abstract methods required by this class. The abstract methods allow this class to get raw data from the sensor.
Depending on the options specified in the constructor, this class may create an integrator. If it needs data
integration, it can set the INTEGRATE or the DOUBLE_INTEGRATE options.
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from class trclib.sensor.TrcSensor
TrcSensor.DataSource<D>, TrcSensor.SensorData<T>
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final int
static final int
private TrcDataIntegrator<TrcAnalogInput.DataType>
protected static TrcElapsedTimer
private final String
-
Constructor Summary
ConstructorsConstructorDescriptionTrcAnalogInput
(String instanceName, int numAxes) Constructor: Creates an instance of the object.TrcAnalogInput
(String instanceName, int numAxes, int options) Constructor: Creates an instance of the object.TrcAnalogInput
(String instanceName, int numAxes, int options, TrcFilter[] filters) Constructor: Creates an instance of the object. -
Method Summary
Modifier and TypeMethodDescriptiongetData
(int index) This method returns the processed sensor data of the specified index.getDoubleIntegratedData
(int index) This method returns the double integrated sensor data of the specified index.getIntegratedData
(int index) This method returns the integrated sensor data of the specified index.getNormalizedData
(int index) This method returns the processed and normalized sensor data of the specified index.abstract TrcSensor.SensorData<Double>
getRawData
(int index, TrcAnalogInput.DataType dataType) This abstract method returns the raw data with the specified index and type.static void
printElapsedTime
(TrcDbgTrace tracer) This method prints the elapsed time info using the given tracer.void
resetIntegrator
(int index) This method resets the integrator of the specified index.static void
setElapsedTimerEnabled
(boolean enabled) This method enables/disables the elapsed timers for performance monitoring.void
setEnabled
(boolean enabled) The method enables/disables the processing of sensor data.void
setInverted
(boolean inverted) This method inverts the sensor data.void
setScale
(double scale) This method sets the scale factor on the sensor data.void
setScaleAndOffset
(double scale, double offset) This method sets the scale factor on the sensor data.toString()
This method returns the instance name.Methods inherited from class trclib.sensor.TrcSensor
calibrate, calibrate, getNumAxes, getProcessedData, isCalibrating, setInverted, setScale, setScaleAndOffset
-
Field Details
-
ANALOGINPUT_INTEGRATE
public static final int ANALOGINPUT_INTEGRATE- See Also:
-
ANALOGINPUT_DOUBLE_INTEGRATE
public static final int ANALOGINPUT_DOUBLE_INTEGRATE- See Also:
-
getInputElapsedTimer
-
instanceName
-
dataIntegrator
-
-
Constructor Details
-
TrcAnalogInput
Constructor: Creates an instance of the object.- Parameters:
instanceName
- specifies the instance name.numAxes
- specifies the number of axes.options
- specifies the AnalogInput options. Multiple options can be OR'd together. ANALOGINPUT_INTEGRATE - do integration on sensor data. ANALOGINPUT_DOUBLE_INTEGRATE - do double integration on sensor data.filters
- specifies an array of filter objects, one for each axis, to filter sensor data. If no filter is used, this can be set to null.
-
TrcAnalogInput
Constructor: Creates an instance of the object.- Parameters:
instanceName
- specifies the instance name.numAxes
- specifies the number of axes.options
- specifies the AnalogInput options. Multiple options can be OR'd together. ANALOGINPUT_INTEGRATE - do integration on sensor data. ANALOGINPUT_DOUBLE_INTEGRATE - do double integration on sensor data.
-
TrcAnalogInput
Constructor: Creates an instance of the object.- Parameters:
instanceName
- specifies the instance name.numAxes
- specifies the number of axes supporting by the analog input device.
-
-
Method Details
-
getRawData
public abstract TrcSensor.SensorData<Double> getRawData(int index, TrcAnalogInput.DataType dataType) This abstract method returns the raw data with the specified index and type.- Specified by:
getRawData
in classTrcSensor<TrcAnalogInput.DataType>
- Parameters:
index
- specifies the data index.dataType
- specifies the data type.- Returns:
- raw data with the specified type.
-
toString
This method returns the instance name.- Overrides:
toString
in classTrcSensor<TrcAnalogInput.DataType>
- Returns:
- instance name.
-
setEnabled
public void setEnabled(boolean enabled) The method enables/disables the processing of sensor data. It is not automatically enabled when the TrcAnalogInput object is created. You need to explicitly enable the it before data processing will start. As part of enabling the sensor, calibrate() is also called. calibrate() may be overridden by the platform dependent sensor if it is capable of doing its own. Otherwise, calibrate will call the built-in calibrator to do the calibration. Enabling/disabling data processing for the sensor involves enabling/disabling the integrator if it exists.- Parameters:
enabled
- specifies true if enabling, false otherwise.
-
setElapsedTimerEnabled
public static void setElapsedTimerEnabled(boolean enabled) This method enables/disables the elapsed timers for performance monitoring.- Parameters:
enabled
- specifies true to enable elapsed timers, false to disable.
-
printElapsedTime
This method prints the elapsed time info using the given tracer.- Parameters:
tracer
- specifies the tracer to be used to print the info.
-
setInverted
public void setInverted(boolean inverted) This method inverts the sensor data. This is useful if the orientation of the sensor is such that the data goes the wrong direction.- Parameters:
inverted
- specifies true to invert sensor data, false otherwise.
-
setScaleAndOffset
public void setScaleAndOffset(double scale, double offset) This method sets the scale factor on the sensor data.- Parameters:
scale
- specifies the scale factor.offset
- specifies the offset to be subtracted from the scaled data.
-
setScale
public void setScale(double scale) This method sets the scale factor on the sensor data.- Parameters:
scale
- specifies the scale factor.
-
getData
This method returns the processed sensor data of the specified index.- Parameters:
index
- specifies the data index.- Returns:
- processed data.
-
getNormalizedData
This method returns the processed and normalized sensor data of the specified index.- Parameters:
index
- specifies the data index.- Returns:
- processed normalized data.
-
getIntegratedData
This method returns the integrated sensor data of the specified index.- Parameters:
index
- specifies the data index.- Returns:
- integrated sensor data.
-
getDoubleIntegratedData
This method returns the double integrated sensor data of the specified index.- Parameters:
index
- specifies the data index.- Returns:
- double integrated sensor data.
-
resetIntegrator
public void resetIntegrator(int index) This method resets the integrator of the specified index.- Parameters:
index
- specifies the data index.
-