Class PhotonVisionWrapper
java.lang.Object
yall.VisionCamera
yall.cameras.PhotonVisionWrapper
- All Implemented Interfaces:
AutoCloseable
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.
-
Field Summary
Fields inherited from class VisionCamera
config, name -
Constructor Summary
ConstructorsConstructorDescriptionPhotonVisionWrapper(org.photonvision.PhotonCamera camera, VisionCameraConfig config) Wraps a PhotonVision camera. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidapplyPipelineIndex(int index) Switches the real camera's pipeline.protected voidapplyRobotOrientation(double timestampSeconds, Rotation3d orientation, double yawRateDegreesPerSecond) Passes the robot orientation to the real camera, for cameras that use it themselves.protected voidapplyRobotToCamera(Transform3d robotToCamera) Passes a new camera position to the real camera, for cameras that use it themselves.org.photonvision.PhotonCameraThe vendor's camera object, for settings YALL doesn't cover.org.photonvision.PhotonPoseEstimatorPhotonVision's pose estimator for this camera's real results, for settings YALL doesn't cover.protected booleanWhether the real camera is sending data.protected List<VisionFrame> Reads the frames the real camera produced since the last call.protected intReads the real camera's pipeline.Methods inherited from class VisionCamera
addVisionMeasurements, cacheRobotToCamera, checkEstimate, close, forEachEstimatedPose, getBestTarget, getCameraFieldPose, getCameraSim, getCameraYawOnRobot, getConfig, getEstimatedPose, getEstimatedPoses, getFilterStats, getLastRejectionReason, getLatestResult, getName, getPipelineIndex, getRejectedPoses, getRobotToCamera, getSimulatedPoseEstimator, getTargets, getUnreadResults, getVisionSim, hasTargets, isConnected, isSimulated, resetFilterStats, setPipelineIndex, setRobotOrientation, setRobotOrientation, setRobotOrientation, setRobotToCamera, setRobotToCamera, update
-
Constructor Details
-
PhotonVisionWrapper
Wraps a PhotonVision camera.- Parameters:
camera- The PhotonVision camera.config- The camera's config.
-
-
Method Details
-
readFrames
Description copied from class:VisionCameraReads the frames the real camera produced since the last call. Call once per loop.- Specified by:
readFramesin classVisionCamera- Returns:
- The frames, oldest first.
-
applyRobotOrientation
protected void applyRobotOrientation(double timestampSeconds, Rotation3d orientation, double yawRateDegreesPerSecond) Description copied from class:VisionCameraPasses the robot orientation to the real camera, for cameras that use it themselves.- Overrides:
applyRobotOrientationin classVisionCamera- Parameters:
timestampSeconds- When the orientation was measured.orientation- Robot orientation on the field.yawRateDegreesPerSecond- Yaw rate, or NaN if unknown.
-
applyRobotToCamera
Description copied from class:VisionCameraPasses a new camera position to the real camera, for cameras that use it themselves.- Overrides:
applyRobotToCamerain classVisionCamera- Parameters:
robotToCamera- Transform from the robot origin to the camera.
-
applyPipelineIndex
protected void applyPipelineIndex(int index) Description copied from class:VisionCameraSwitches the real camera's pipeline.- Specified by:
applyPipelineIndexin classVisionCamera- Parameters:
index- Pipeline index.
-
readPipelineIndex
protected int readPipelineIndex()Description copied from class:VisionCameraReads the real camera's pipeline.- Specified by:
readPipelineIndexin classVisionCamera- Returns:
- Pipeline index.
-
readConnected
protected boolean readConnected()Description copied from class:VisionCameraWhether the real camera is sending data.- Specified by:
readConnectedin classVisionCamera- 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: seeVisionCamera.getSimulatedPoseEstimator().- Returns:
- The pose estimator.
-
getCamera
public org.photonvision.PhotonCamera getCamera()Description copied from class:VisionCameraThe vendor's camera object, for settings YALL doesn't cover. Each wrapper narrows the return type to its vendor's class.- Specified by:
getCamerain classVisionCamera- Returns:
- The vendor's camera object.
-