Record Class VisionResult

java.lang.Object
java.lang.Record
yall.results.VisionResult
Record Components:
cameraName - Name of the camera that produced the frame.
timestampSeconds - When the image was captured, on the Timer.getMonotonicTimestamp() timebase that WPILib's pose estimators use.
latencyMillis - Time from capture to the result reaching the robot, in milliseconds.
targets - Targets in the frame, best first.

public record VisionResult(String cameraName, double timestampSeconds, double latencyMillis, List<VisionTarget> targets) extends Record
One processed camera frame, in the same form for every camera vendor.
  • Constructor Details

    • VisionResult

      public VisionResult(String cameraName, double timestampSeconds, double latencyMillis, List<VisionTarget> targets)
      Copies the target list so the result can't change after it is made.
  • Method Details

    • hasTargets

      public boolean hasTargets()
      Whether the frame has any targets.
      Returns:
      true if targets() isn't empty.
    • getBestTarget

      public Optional<VisionTarget> getBestTarget()
      The best target in the frame, as ranked by the camera.
      Returns:
      The first target, or empty if there are none.
    • getAprilTags

      public List<VisionTarget> getAprilTags()
      The AprilTags in the frame.
      Returns:
      Targets with a fiducial ID.
    • getDetectedObjects

      public List<VisionTarget> getDetectedObjects()
      The detected objects in the frame.
      Returns:
      Targets with an object detection class ID.
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with the compare method from their corresponding wrapper classes.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • cameraName

      public String cameraName()
      Returns the value of the cameraName record component.
      Returns:
      the value of the cameraName record component
    • timestampSeconds

      public double timestampSeconds()
      Returns the value of the timestampSeconds record component.
      Returns:
      the value of the timestampSeconds record component
    • latencyMillis

      public double latencyMillis()
      Returns the value of the latencyMillis record component.
      Returns:
      the value of the latencyMillis record component
    • targets

      public List<VisionTarget> targets()
      Returns the value of the targets record component.
      Returns:
      the value of the targets record component