Package trclib.sensor

Class TrcSensorCalibrator<D>

java.lang.Object
trclib.sensor.TrcSensorCalibrator<D>
Type Parameters:
D - specifies the sensor data type to be calibrated.

public class TrcSensorCalibrator<D> extends Object
This class implements a generic sensor calibrator on a given sensor with the specified data type.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private final D
     
    private final double[]
     
    private final String
     
    private final int
     
    private final TrcSensor<D>
     
    private final double[]
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    TrcSensorCalibrator(String instanceName, TrcSensor<D> sensor, int numAxes, D dataType)
    Constructor: Creates an instance of the object.
  • Method Summary

    Modifier and Type
    Method
    Description
    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.
    double
    getCalibratedData(int index, double data)
    This method applies the calibrated result to the raw sensor data and returned the calibrated data.
    This method returns the instance name.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Field Details

    • instanceName

      private final String instanceName
    • sensor

      private final TrcSensor<D> sensor
    • numAxes

      private final int numAxes
    • dataType

      private final D dataType
    • zeroOffsets

      private final double[] zeroOffsets
    • deadbands

      private final double[] deadbands
  • Constructor Details

    • TrcSensorCalibrator

      public TrcSensorCalibrator(String instanceName, TrcSensor<D> sensor, int numAxes, D dataType)
      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

      public String toString()
      This method returns the instance name.
      Overrides:
      toString in class Object
      Returns:
      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.