photonlibpy.photonPoseEstimator
PhotonPoseEstimator
The PhotonPoseEstimator class filters or combines readings from all the AprilTags visible at a given timestamp on the field to produce a single robot in field pose, using the strategy set below. Example usage can be found in our apriltagExample example project.
fieldTags
property
writable
Get the AprilTagFieldLayout being used by the PositionEstimator.
Note: Setting the origin of this layout will affect the results from this class.
:returns: the AprilTagFieldLayout
primaryStrategy
property
writable
Get the Position Estimation Strategy being used by the Position Estimator.
:returns: the strategy
referencePose
property
writable
Return the reference position that is being used by the estimator.
:returns: the referencePose
__init__(fieldTags, strategy, camera, robotToCamera)
Create a new PhotonPoseEstimator.
:param fieldTags: A WPILib AprilTagFieldLayout linking AprilTag IDs to Pose3d objects with respect to the FIRST field using the Field Coordinate System. Note that setting the origin of this layout object will affect the results from this class. :param strategy: The strategy it should use to determine the best pose. :param camera: PhotonCamera :param robotToCamera: Transform3d from the center of the robot to the camera mount position (i.e., robot ➔ camera) in the Robot Coordinate System.
update(cameraResult=None)
Updates the estimated position of the robot. Returns empty if:
-
The timestamp of the provided pipeline result is the same as in the previous call to
update()
. -
No targets were found in the pipeline results.
:param cameraResult: The latest pipeline result from the camera
:returns: an :class:EstimatedRobotPose
with an estimated pose, timestamp, and targets used to
create the estimate.
PoseStrategy
Bases: Enum
Position estimation strategies that can be used by the PhotonPoseEstimator class.
AVERAGE_BEST_TARGETS = enum.auto()
class-attribute
instance-attribute
Return the average of the best target poses using ambiguity as weight.
CLOSEST_TO_CAMERA_HEIGHT = enum.auto()
class-attribute
instance-attribute
Choose the Pose which is closest to the camera height.
CLOSEST_TO_LAST_POSE = enum.auto()
class-attribute
instance-attribute
Choose the Pose which is closest to the last pose calculated.
CLOSEST_TO_REFERENCE_POSE = enum.auto()
class-attribute
instance-attribute
Choose the Pose which is closest to a set Reference position.
LOWEST_AMBIGUITY = enum.auto()
class-attribute
instance-attribute
Choose the Pose with the lowest ambiguity.
MULTI_TAG_PNP_ON_COPROCESSOR = enum.auto()
class-attribute
instance-attribute
Use all visible tags to compute a single pose estimate on coprocessor. This option needs to be enabled on the PhotonVision web UI as well.
MULTI_TAG_PNP_ON_RIO = enum.auto()
class-attribute
instance-attribute
Use all visible tags to compute a single pose estimate. This runs on the RoboRIO, and can take a lot of time.