PhotonVision

public class PhotonVision extends SubsystemBase

The PhotonVision class is a subsystem that interfaces with multiple PhotonVision cameras to provide vision tracking and pose estimation capabilities. This subsystem is a Singleton that manages multiple CameraModules and selects the best result based on pose ambiguity.

This subsystem provides methods to get the estimated global pose of the robot, the distance to targets, and the yaw of detected AprilTags. It also provides methods to check if a tag is visible and get the pivot position based on distance calculations.

Properties

Link copied to clipboard
public PhotonTrackedTarget currentTarget
Link copied to clipboard
public double dist
Link copied to clipboard
public double targetPoseAmbiguity
Link copied to clipboard
public double y
Link copied to clipboard
public double yaw

Functions

Link copied to clipboard
public PhotonTrackedTarget getCurrentTarget()
Gets the current tracked target.
Link copied to clipboard
public double getDist()
Link copied to clipboard
public double getDistanceAprilTag()
Calculates the straight-line distance to the currently tracked AprilTag.
Link copied to clipboard
public Transform3d getEstimatedGlobalPose()
Gets the estimated global pose of the robot as a Transform3d.
public EstimatedRobotPose getEstimatedGlobalPose(Pose2d prevEstimatedRobotPose)
Gets the estimated global pose of the robot using the best available camera.
Link copied to clipboard
public static PhotonVision getInstance()
Returns the Singleton instance of this PhotonVision subsystem.
Link copied to clipboard
public double getPivotPosition()
Calculates the pivot position based on the distance to the AprilTag.
Link copied to clipboard
public double getTargetPoseAmbiguity()
Gets the current target pose ambiguity.
Link copied to clipboard
public double getY()
Link copied to clipboard
public double getYaw()
Gets the current yaw angle to the target.
Link copied to clipboard
public boolean hasTag()
Checks if there is a visible AprilTag.
Link copied to clipboard
public void periodic()
This method is called periodically by the CommandScheduler.