Class AprilTagVisionSubsystem

java.lang.Object
edu.wpi.first.wpilibj2.command.SubsystemBase
frc.robot.shared.subsystems.AbstractSubsystem<AprilTagVisionSubsystemConfig>
frc.robot.subsystems.apriltagvision.AprilTagVisionSubsystem
All Implemented Interfaces:
edu.wpi.first.util.sendable.Sendable, edu.wpi.first.wpilibj2.command.Subsystem

public class AprilTagVisionSubsystem extends AbstractSubsystem<AprilTagVisionSubsystemConfig>
Subsystem that processes AprilTag camera observations for robot pose estimation.

Uses AprilTag detection via PhotonVision to provide pose corrections for the robot state estimator. Pose filtering and uncertainty calculation are delegated to AprilTagPoseEstimator.

  • Constructor Details

    • AprilTagVisionSubsystem

      public AprilTagVisionSubsystem(AprilTagVisionSubsystemConfig config, VisionMeasurementConsumer consumer, Consumer<edu.wpi.first.math.geometry.Pose2d> odometryResetConsumer, Supplier<edu.wpi.first.math.geometry.Pose2d> poseSupplier)
      Creates a new AprilTagVisionSubsystem.

      Call this once during robot setup. The subsystem owns the camera I/O objects and streams accepted measurements to the consumer. The field layout is loaded from the subsystem config so each robot variant can specify its own AprilTag field layout.

      Parameters:
      config - configuration for vision processing, field layout, and tunable thresholds
      consumer - consumer that receives accepted pose measurements with standard deviations
      odometryResetConsumer - consumer that hard-resets odometry to a given pose in meters and radians; called once when the first vision measurement is accepted during the initial acceptance window to establish a reliable baseline
      poseSupplier - supplier for the current robot pose in meters and radians (used for simulation). Use raw odometry or ground-truth poses, not the fused robot state pose, to avoid feedback loops in sim.
  • Method Details

    • periodic

      public void periodic()
      Pulls the latest frames from each camera, filters pose observations, and forwards accepted measurements to the robot state estimator.