Record Class VisionTarget

java.lang.Object
java.lang.Record
yall.results.VisionTarget
Record Components:
yawDegrees - Horizontal angle from the crosshair to the target, positive right.
pitchDegrees - Vertical angle from the crosshair to the target, positive up.
areaPercent - Share of the image the target covers, 0 to 100. Double.NaN if the camera doesn't report it.
fiducialId - AprilTag ID, or -1 if the target isn't an AprilTag.
classId - Object detection class ID, or -1 if the target isn't a detected object.
confidence - Object detection confidence, 0 to 1. 0 if the target isn't a detected object.
ambiguity - AprilTag pose ambiguity, 0 to 1. Double.NaN if the camera doesn't report it.
cameraToTarget - Transform from the camera to the target, if the camera solved it.

public record VisionTarget(double yawDegrees, double pitchDegrees, double areaPercent, int fiducialId, int classId, double confidence, double ambiguity, Optional<Transform3d> cameraToTarget) extends Record
One target a camera sees, in the same form for every camera vendor.

Angles follow PhotonVision's convention: yaw is positive to the right of the crosshair, pitch is positive above it. Limelight's tx is already positive right; its ty is positive down, so the Limelight wrapper negates it.

  • Constructor Details

    • VisionTarget

      public VisionTarget(double yawDegrees, double pitchDegrees, double areaPercent, int fiducialId, int classId, double confidence, double ambiguity, Optional<Transform3d> cameraToTarget)
      Creates an instance of a VisionTarget record class.
      Parameters:
      yawDegrees - the value for the yawDegrees record component
      pitchDegrees - the value for the pitchDegrees record component
      areaPercent - the value for the areaPercent record component
      fiducialId - the value for the fiducialId record component
      classId - the value for the classId record component
      confidence - the value for the confidence record component
      ambiguity - the value for the ambiguity record component
      cameraToTarget - the value for the cameraToTarget record component
  • Method Details

    • isAprilTag

      public boolean isAprilTag()
      Whether the target is an AprilTag.
      Returns:
      true if fiducialId() is a tag ID.
    • isDetectedObject

      public boolean isDetectedObject()
      Whether the target came from object detection.
      Returns:
      true if classId() is a 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.
    • yawDegrees

      public double yawDegrees()
      Returns the value of the yawDegrees record component.
      Returns:
      the value of the yawDegrees record component
    • pitchDegrees

      public double pitchDegrees()
      Returns the value of the pitchDegrees record component.
      Returns:
      the value of the pitchDegrees record component
    • areaPercent

      public double areaPercent()
      Returns the value of the areaPercent record component.
      Returns:
      the value of the areaPercent record component
    • fiducialId

      public int fiducialId()
      Returns the value of the fiducialId record component.
      Returns:
      the value of the fiducialId record component
    • classId

      public int classId()
      Returns the value of the classId record component.
      Returns:
      the value of the classId record component
    • confidence

      public double confidence()
      Returns the value of the confidence record component.
      Returns:
      the value of the confidence record component
    • ambiguity

      public double ambiguity()
      Returns the value of the ambiguity record component.
      Returns:
      the value of the ambiguity record component
    • cameraToTarget

      public Optional<Transform3d> cameraToTarget()
      Returns the value of the cameraToTarget record component.
      Returns:
      the value of the cameraToTarget record component