Class TrcDataIntegrator<D>

java.lang.Object
trclib.dataprocessor.TrcDataIntegrator<D>

public class TrcDataIntegrator<D> extends Object
This class does data integration for sensors that have one or more axes. Some value sensors such as gyros and accelerometers may need to integrate their data to provide heading from gyro rotation rate, and velocity or distance from accelerometer acceleration data. This class uses a periodic task to do integration and optionally double integration.
  • Field Details

  • Constructor Details

    • TrcDataIntegrator

      public TrcDataIntegrator(String instanceName, TrcSensor<D> sensor, D dataType, boolean doubleIntegration)
      Constructor: Creates an instance of the object.
      Parameters:
      instanceName - specifies the instance name.
      sensor - specifies the sensor object that needs integration.
      dataType - specifies the data type to be integrated.
      doubleIntegration - specifies true to do double integration, false otherwise.
    • TrcDataIntegrator

      public TrcDataIntegrator(String instanceName, TrcSensor<D> sensor, D dataType)
      Constructor: Creates an instance of the object.
      Parameters:
      instanceName - specifies the instance name.
      sensor - specifies the sensor object that needs integration.
      dataType - specifies the data type to be integrated.
  • Method Details

    • toString

      public String toString()
      This method returns the instance name.
      Overrides:
      toString in class Object
      Returns:
      instance name.
    • setEnabled

      public void setEnabled(boolean enabled)
      This method enables the data integrator. The data integrator is not automatically enabled when created. You must explicitly call this method to enable the data integrator.
      Parameters:
      enabled - specifies true for enabling the data processor, disabling it otherwise.
    • reset

      public void reset(int index)
      This method resets the indexed integratedData and doubleIntegratedData.
      Parameters:
      index - specifies the index.
    • reset

      public void reset()
      This method resets all integratorData and doubleIntegratedData.
    • getInputData

      public TrcSensor.SensorData<Double> getInputData(int index)
      This method returns the last indexed input data.
      Parameters:
      index - specifies the index.
      Returns:
      the last indexed input data.
    • getIntegratedData

      public TrcSensor.SensorData<Double> getIntegratedData(int index)
      This method returns the last indexed integrated data.
      Parameters:
      index - specifies the index.
      Returns:
      last indexed integrated data.
    • getDoubleIntegratedData

      public TrcSensor.SensorData<Double> getDoubleIntegratedData(int index)
      This method returns the last indexed double integrated data.
      Parameters:
      index - specifies the index.
      Returns:
      last indexed double integrated data.
    • integratorTask

      private void integratorTask(TrcTaskMgr.TaskType taskType, TrcRobot.RunMode runMode, boolean slowPeriodicLoop)
      This method is called periodically to do data integration.
      Parameters:
      taskType - specifies the type of task being run.
      runMode - specifies the competition mode that is running.
      slowPeriodicLoop - specifies true if it is running the slow periodic loop on the main robot thread, false otherwise.