Package frclib.vision

Class FrcRemoteVisionProcessor

java.lang.Object
frclib.vision.FrcRemoteVisionProcessor

public abstract class FrcRemoteVisionProcessor extends Object
  • Field Details

    • tracer

      protected final TrcDbgTrace tracer
    • instanceName

      protected final String instanceName
  • Constructor Details

    • FrcRemoteVisionProcessor

      public FrcRemoteVisionProcessor(String instanceName)
      Constructor: Create an instance of the object.
      Parameters:
      instanceName - specifies the instance name.
  • Method Details

    • getTargetData

      protected abstract FrcRemoteVisionProcessor.TargetData<?> getTargetData()
      This method gets the latest target data from vision processor.
      Returns:
      target data of the detected object, null if no object detected.
    • getTargetPose

      protected abstract TrcPose2D getTargetPose(FrcRemoteVisionProcessor.TargetData<?> targetData)
      This method gets the target pose from the detected target data.
      Parameters:
      targetData - specifies the target data from which to get the target pose.
      Returns:
      detected target pose.
    • 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/disables the vision processor task.
      Parameters:
      enabled - specifies true to enable vision process task, false to disable.
    • setFreshnessTimeout

      public void setFreshnessTimeout(double timeout)
      This method sets the timeout of a relative pose.
      Parameters:
      timeout - specifies relative pose timeout in seconds.
    • setMaxCachedFrames

      public void setMaxCachedFrames(int numFrames)
      Set the max number of frames to keep. You will not be able to average more frames than this.
      Parameters:
      numFrames - How many frames to keep for averaging at maximum.
    • getLastTargetData

      public FrcRemoteVisionProcessor.TargetData<?> getLastTargetData()
      Gets the last calculated pose.
      Returns:
      The pose calculated by the vision system. If no object detected, returns null.
    • getAveragePose

      public TrcPose2D getAveragePose(int numFrames, boolean requireAll)
      Calculates the average pose of the last numFrames frames, optionally requiring numFrames frames.
      Parameters:
      numFrames - How many frames to average.
      requireAll - If true, require at least numFrames frames to average.
      Returns:
      Average of last numFrames frames, or null if not enough frames and requireAll is true.
    • getAveragePose

      public TrcPose2D getAveragePose(int numFrames)
      Calculates the average pose of the last numFrames frames.
      Parameters:
      numFrames - How many frames to average.
      Returns:
      The average pose.
    • getAveragePose

      public TrcPose2D getAveragePose()
      Get the average pose of the last n frames where n=maxCachedFrames.
      Returns:
      The average pose. (all attributes averaged)
    • getMedianPose

      public TrcPose2D getMedianPose(int numFrames, boolean requireAll)
      Calculates the median pose of the last numFrames frames, optionally requiring numFrames frames.
      Parameters:
      numFrames - How many frames to calculate with.
      requireAll - If true, require at least numFrames frames.
      Returns:
      Median of last numFrames frames, or null if not enough frames and requireAll is true, or if all data is stale.