PhotonVision C++ dev-v2025.0.0-beta-8-2-gbd1c5c03
Loading...
Searching...
No Matches
photon::PhotonPoseEstimator Class Reference

The PhotonPoseEstimator class filters or combines readings from all the fiducials visible at a given timestamp on the field to produce a single robot in field pose, using the strategy set below. More...

#include <photon/PhotonPoseEstimator.h>

Public Member Functions

 PhotonPoseEstimator (frc::AprilTagFieldLayout aprilTags, PoseStrategy strategy, frc::Transform3d robotToCamera)
 Create a new PhotonPoseEstimator.
 
frc::AprilTagFieldLayout GetFieldLayout () const
 Get the AprilTagFieldLayout being used by the PositionEstimator.
 
PoseStrategy GetPoseStrategy () const
 Get the Position Estimation Strategy being used by the Position Estimator.
 
void SetPoseStrategy (PoseStrategy strat)
 Set the Position Estimation Strategy used by the Position Estimator.
 
void SetMultiTagFallbackStrategy (PoseStrategy strategy)
 Set the Position Estimation Strategy used in multi-tag mode when only one tag can be seen.
 
frc::Pose3d GetReferencePose () const
 Return the reference position that is being used by the estimator.
 
void SetReferencePose (frc::Pose3d referencePose)
 Update the stored reference pose for use when using the CLOSEST_TO_REFERENCE_POSE strategy.
 
frc::Transform3d GetRobotToCameraTransform ()
 
void SetRobotToCameraTransform (frc::Transform3d robotToCamera)
 Useful for pan and tilt mechanisms, or cameras on turrets.
 
void SetLastPose (frc::Pose3d lastPose)
 Update the stored last pose.
 
std::optional< EstimatedRobotPoseUpdate (const PhotonPipelineResult &result, std::optional< PhotonCamera::CameraMatrix > cameraMatrixData=std::nullopt, std::optional< PhotonCamera::DistortionMatrix > coeffsData=std::nullopt)
 Update the pose estimator.
 

Detailed Description

The PhotonPoseEstimator class filters or combines readings from all the fiducials 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.

Constructor & Destructor Documentation

◆ PhotonPoseEstimator()

photon::PhotonPoseEstimator::PhotonPoseEstimator ( frc::AprilTagFieldLayout aprilTags,
PoseStrategy strategy,
frc::Transform3d robotToCamera )
explicit

Create a new PhotonPoseEstimator.

Parameters
aprilTagsA AprilTagFieldLayout linking AprilTag IDs to Pose3ds with respect to the FIRST field.
strategyThe strategy it should use to determine the best pose.
robotToCameraTransform3d from the center of the robot to the camera mount positions (ie, robot ➔ camera).

Member Function Documentation

◆ GetFieldLayout()

frc::AprilTagFieldLayout photon::PhotonPoseEstimator::GetFieldLayout ( ) const
inline

Get the AprilTagFieldLayout being used by the PositionEstimator.

Returns
the AprilTagFieldLayout

◆ GetPoseStrategy()

PoseStrategy photon::PhotonPoseEstimator::GetPoseStrategy ( ) const
inline

Get the Position Estimation Strategy being used by the Position Estimator.

Returns
the strategy

◆ GetReferencePose()

frc::Pose3d photon::PhotonPoseEstimator::GetReferencePose ( ) const
inline

Return the reference position that is being used by the estimator.

Returns
the referencePose

◆ GetRobotToCameraTransform()

frc::Transform3d photon::PhotonPoseEstimator::GetRobotToCameraTransform ( )
inline
Returns
The current transform from the center of the robot to the camera mount position.

◆ SetLastPose()

void photon::PhotonPoseEstimator::SetLastPose ( frc::Pose3d lastPose)
inline

Update the stored last pose.

Useful for setting the initial estimate when using the CLOSEST_TO_LAST_POSE strategy.

Parameters
lastPosethe lastPose to set

◆ SetMultiTagFallbackStrategy()

void photon::PhotonPoseEstimator::SetMultiTagFallbackStrategy ( PoseStrategy strategy)

Set the Position Estimation Strategy used in multi-tag mode when only one tag can be seen.

Must NOT be MULTI_TAG_PNP

Parameters
strategythe strategy to set

◆ SetPoseStrategy()

void photon::PhotonPoseEstimator::SetPoseStrategy ( PoseStrategy strat)
inline

Set the Position Estimation Strategy used by the Position Estimator.

Parameters
strategythe strategy to set

◆ SetReferencePose()

void photon::PhotonPoseEstimator::SetReferencePose ( frc::Pose3d referencePose)
inline

Update the stored reference pose for use when using the CLOSEST_TO_REFERENCE_POSE strategy.

Parameters
referencePosethe referencePose to set

◆ SetRobotToCameraTransform()

void photon::PhotonPoseEstimator::SetRobotToCameraTransform ( frc::Transform3d robotToCamera)
inline

Useful for pan and tilt mechanisms, or cameras on turrets.

Parameters
robotToCameraThe current transform from the center of the robot to the camera mount position.

◆ Update()

std::optional< EstimatedRobotPose > photon::PhotonPoseEstimator::Update ( const PhotonPipelineResult & result,
std::optional< PhotonCamera::CameraMatrix > cameraMatrixData = std::nullopt,
std::optional< PhotonCamera::DistortionMatrix > coeffsData = std::nullopt )

Update the pose estimator.

If updating multiple times per loop, you should call this exactly once per new result, in order of increasing result timestamp.

Parameters
resultThe vision targeting result to process
cameraIntrinsicsThe camera calibration pinhole coefficients matrix. Only required if doing multitag-on-rio, and may be nullopt otherwise.
distCoeffsDataThe camera calibration distortion coefficients. Only required if doing multitag-on-rio, and may be nullopt otherwise.

The documentation for this class was generated from the following file: