Class OrinSolver

java.lang.Object
frc.robot.subsystems.vision.OrinSolver

public final class OrinSolver extends Object
Turns one Orin camera's logged PhotonLib results into pose observations. Reads only OrinCameraInputs and robot state that is itself replayed, so it runs identically live and in replay (issue #10, section 2).
  • Multi-tag: the Jetson's multi-tag solve (estimatedPose.best). Tag count and distance come from fiducialIDsUsed, not every visible target (section 10a).
  • Single tag: the lowest-ambiguity usable tag. Of its two PnP candidates, the one whose heading is closest to the gyro's at the frame's timestamp (6328, section 8b); the ambiguity gate in VisionGates.orinGates(DoubleSupplier) then drops frames where the two are too alike.
  • Targets with fiducialId < 0 (game pieces), tags missing from the layout and tags on the excluded list (section 12) are never used. The Jetson already leaves excluded tags out of multi-tag; this keeps them out of the single-tag path too.
  • Each observation's std-dev scale is the camera's factor times edgeScale(PhotonTrackedTarget): tags near the image edge are trusted less, not dropped (section 8b).
  • Field Details

    • EDGE_BAND_PX

      public static final double EDGE_BAND_PX
      Std-dev falloff starts this far (px) from the image edge.
      See Also:
    • EDGE_MAX_SCALE

      public static final double EDGE_MAX_SCALE
      Std-dev multiplier at the very edge; 1.0 turns the edge scaling off.
      See Also:
    • decodeFailures

      public int decodeFailures
      Stats from the most recent solve(OrinCameraInputs, Set, DoubleFunction) call, for logging.
    • excludedTargets

      public int excludedTargets
    • decoded

      public final List<org.photonvision.targeting.PhotonPipelineResult> decoded
      The last solve(OrinCameraInputs, Set, DoubleFunction) call's decoded results, oldest first, for sources built on them.
    • seenTags

      public final BitSet seenTags
      Every fiducial id seen in the last solve(OrinCameraInputs, Set, DoubleFunction) call's results.
    • lastLatencyMs

      public double lastLatencyMs
    • lastTimestampSeconds

      public double lastTimestampSeconds
  • Constructor Details

    • OrinSolver

      public OrinSolver(Transform3d robotToCamera, AprilTagFieldLayout layout, double cameraFactor, int imageWidth, int imageHeight)
      Parameters:
      robotToCamera - camera mount, robot frame (x forward, y left, z up)
      layout - the field's AprilTags; must match the Jetson's
      cameraFactor - per-camera std-dev multiplier (6328's camera factor)
      imageWidth - image width in px (the Jetson's images are 1280x800)
      imageHeight - image height in px
  • Method Details

    • cameraFactor

      public double cameraFactor()
      This camera's std-dev factor.
    • decode

      public Optional<org.photonvision.targeting.PhotonPipelineResult> decode(byte[] bytes)
      Decodes one logged result, or empty if the bytes are bad (PhotonVision #2528).
    • solve

      public List<PoseObservation> solve(OrinCameraInputs inputs, Set<Integer> excludedTags, DoubleFunction<Rotation2d> headingAt)
      Solves every logged result.
      Parameters:
      inputs - this loop's camera inputs
      excludedTags - tag ids to leave out (section 12)
      headingAt - the robot's heading at a capture time, or null if unknown (before the pose is seeded); picks between single-tag candidates
      Returns:
      one observation per result that had a usable tag
    • edgeScale

      public double edgeScale(org.photonvision.targeting.PhotonTrackedTarget t)
      1.0 away from the image edges, rising smoothly to EDGE_MAX_SCALE as the tag's closest corner reaches an edge. Near the edge lens distortion is strongest, the calibration has the least data, and tags are often cut off.