Package trclib.sensor
Class TrcSensorCalibrator<D>
java.lang.Object
trclib.sensor.TrcSensorCalibrator<D>
- Type Parameters:
D
- specifies the sensor data type to be calibrated.
This class implements a generic sensor calibrator on a given sensor with the specified data type.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionTrcSensorCalibrator
(String instanceName, TrcSensor<D> sensor, int numAxes, D dataType) Constructor: Creates an instance of the object. -
Method Summary
Modifier and TypeMethodDescriptionvoid
calibrate
(int numCalSamples, long calInterval) This method calibrates the sensor by reading a number of sensor data samples, averaging the data to determine the zero offset.double
getCalibratedData
(int index, double data) This method applies the calibrated result to the raw sensor data and returned the calibrated data.toString()
This method returns the instance name.
-
Field Details
-
instanceName
-
sensor
-
numAxes
private final int numAxes -
dataType
-
zeroOffsets
private final double[] zeroOffsets -
deadbands
private final double[] deadbands
-
-
Constructor Details
-
TrcSensorCalibrator
Constructor: Creates an instance of the object.- Parameters:
instanceName
- specifies the instance name.sensor
- specifies the sensor to perform the calibration on.numAxes
- specifies the number of axes needs to be calibrated.dataType
- specifies the sensor data type to be calibrated.
-
-
Method Details
-
toString
This method returns the instance name. -
calibrate
public void calibrate(int numCalSamples, long calInterval) This method calibrates the sensor by reading a number of sensor data samples, averaging the data to determine the zero offset. It also determines the min and max values of the data samples to form the deadband.- Parameters:
numCalSamples
- specifies the number of calibration sample to take.calInterval
- specifies the interval between each calibration sample in msec.
-
getCalibratedData
public double getCalibratedData(int index, double data) This method applies the calibrated result to the raw sensor data and returned the calibrated data.- Parameters:
index
- specifies the axis of the sensor calibration to be applied to the data.data
- specifies the raw sensor data to be calibrated.- Returns:
- calibrated sensor data.
-