Class AprilTagPoseEstimator

java.lang.Object
frc.robot.subsystems.apriltagvision.AprilTagPoseEstimator

public class AprilTagPoseEstimator extends Object
Processes AprilTag pose observations and produces vision measurements suitable for pose estimation.

This class encapsulates the filtering and standard deviation calculation logic, making it testable without requiring PhotonVision, subsystem infrastructure, or AdvantageKit logging.

  • Constructor Details

    • AprilTagPoseEstimator

      public AprilTagPoseEstimator(AprilTagPoseEstimator.Params params, Supplier<edu.wpi.first.math.geometry.Pose2d> odometryPoseSupplier)
      Creates a new AprilTagPoseEstimator.
      Parameters:
      params - configuration parameters for filtering and uncertainty
      odometryPoseSupplier - supplier for the current odometry pose used for consistency checking
  • Method Details

    • isWithinInitialAcceptanceWindow

      public boolean isWithinInitialAcceptanceWindow()
      Returns whether the estimator is still within the initial pose acceptance window.

      While this returns true, the odometry deviation filter is bypassed so the pose estimator can lock onto a real field position at startup.

      Returns:
      true if the accepted measurement count has not yet reached the configured initial acceptance count
    • estimate

      Processes a pose observation and returns an estimation result.

      Standard deviations are scaled by distance squared divided by tag count, using meters for distance. When the set of observed tag IDs changes between consecutive frames from the same camera, the standard deviations are further multiplied by the tag-switch multiplier to dampen jitter from same-face tag pairs.

      Parameters:
      observation - the raw pose observation from vision
      cameraName - the name of the camera that produced this observation
      Returns:
      estimation result containing the measurement or rejection reason