Class PhotonVisionWrapper

java.lang.Object
yall.VisionCamera
yall.cameras.PhotonVisionWrapper
All Implemented Interfaces:
AutoCloseable

public class PhotonVisionWrapper extends VisionCamera
A PhotonVision camera.

In simulation, PhotonVision's camera simulation publishes to this PhotonCamera, so code that uses getCamera() directly sees simulated results too. Let this wrapper read the results: PhotonCamera.getAllUnreadResults() hands each result out only once.

Pose estimates come from PhotonPoseEstimator: the coprocessor's multi-tag result, falling back to the lowest-ambiguity single tag. With PoseEstimationMode.HEADING_ASSISTED it tries the PnP distance trig solve first.

Without a camera model in the config, it is simulated as a CameraModel.ARDUCAM_OV9281.

No vendor configs are accepted; use getCamera() for PhotonVision settings.

  • Constructor Details

    • PhotonVisionWrapper

      public PhotonVisionWrapper(org.photonvision.PhotonCamera camera, VisionCameraConfig config)
      Wraps a PhotonVision camera.
      Parameters:
      camera - The PhotonVision camera.
      config - The camera's config.
  • Method Details

    • readFrames

      protected List<VisionFrame> readFrames()
      Description copied from class: VisionCamera
      Reads the frames the real camera produced since the last call. Call once per loop.
      Specified by:
      readFrames in class VisionCamera
      Returns:
      The frames, oldest first.
    • applyRobotOrientation

      protected void applyRobotOrientation(double timestampSeconds, Rotation3d orientation, double yawRateDegreesPerSecond)
      Description copied from class: VisionCamera
      Passes the robot orientation to the real camera, for cameras that use it themselves.
      Overrides:
      applyRobotOrientation in class VisionCamera
      Parameters:
      timestampSeconds - When the orientation was measured.
      orientation - Robot orientation on the field.
      yawRateDegreesPerSecond - Yaw rate, or NaN if unknown.
    • applyRobotToCamera

      protected void applyRobotToCamera(Transform3d robotToCamera)
      Description copied from class: VisionCamera
      Passes a new camera position to the real camera, for cameras that use it themselves.
      Overrides:
      applyRobotToCamera in class VisionCamera
      Parameters:
      robotToCamera - Transform from the robot origin to the camera.
    • applyPipelineIndex

      protected void applyPipelineIndex(int index)
      Description copied from class: VisionCamera
      Switches the real camera's pipeline.
      Specified by:
      applyPipelineIndex in class VisionCamera
      Parameters:
      index - Pipeline index.
    • readPipelineIndex

      protected int readPipelineIndex()
      Description copied from class: VisionCamera
      Reads the real camera's pipeline.
      Specified by:
      readPipelineIndex in class VisionCamera
      Returns:
      Pipeline index.
    • readConnected

      protected boolean readConnected()
      Description copied from class: VisionCamera
      Whether the real camera is sending data.
      Specified by:
      readConnected in class VisionCamera
      Returns:
      true if connected.
    • getPhotonPoseEstimator

      public org.photonvision.PhotonPoseEstimator getPhotonPoseEstimator()
      PhotonVision's pose estimator for this camera's real results, for settings YALL doesn't cover. In simulation, the simulation has its own: see VisionCamera.getSimulatedPoseEstimator().
      Returns:
      The pose estimator.
    • getCamera

      public org.photonvision.PhotonCamera getCamera()
      Description copied from class: VisionCamera
      The vendor's camera object, for settings YALL doesn't cover. Each wrapper narrows the return type to its vendor's class.
      Specified by:
      getCamera in class VisionCamera
      Returns:
      The vendor's camera object.