Wheel odometry tracks motion accurately over short timeframes, but wheel slip, carpet compliance, and robot-to-robot collisions introduce cumulative drift over the course of a match.
Stage 5 teaches how to integrate optical vision systems (Limelight and PhotonVision) using 3D AprilTags, fusing vision updates into an Extended Kalman Filter (SwerveDrivePoseEstimator) to maintain centimeter-level field localization.
The Vision Localization Pipeline
Section titled “The Vision Localization Pipeline”[ Camera Sees AprilTags ] --> [ Solve 3D PnP Pose ] --> [ SwerveDrivePoseEstimator ] --> [ True Field Pose2d ] ▲ [ High-Speed Wheel Odometry ] ─┘- Optical Capture: An onboard coprocessor (Limelight or Raspberry/Orange Pi) identifies the 4 corners of visible fiducial markers.
- PnP 3D Solution: Mathematical solver calculates camera position and orientation relative to known field coordinates.
- Kalman Fusion: Blends high-frequency (250 Hz) wheel odometry with latency-corrected vision measurements.
- Target Alignment: Commands drivebase directly toward scoring objectives with single-button driver automation.
For mathematical deep dives on Perspective-n-Point (PnP) geometry and Extended Kalman Filter state updates, consult the Vision Localization Handbook.
Verified Sources & Standards
- WPILib Pose Estimation & Odometry Fusiondocs.wpilib.orgWPILib Standard
- PhotonVision Documentation & 3D AprilTag Trackingdocs.photonvision.orgCommunity Reference
Lessons
AprilTag Geometry & MegaTag Algorithms
3D coordinate systems, camera calibration, mounting offsets, Perspective-n-Point solvers, and MegaTag1 vs MegaTag2.
Swerve Pose Estimator & Vision Fusion
Fusing wheel odometry with latency-compensated vision measurements in SwerveDrivePoseEstimator with dynamic standard deviations.
Automated Alignment & Dynamic Targeting
Target tracking, heading lock PID, on-the-fly drive-to-pose commands, and speaker/reef scoring alignment.