Detecting a tag is one thing; getting a reliable field pose from it is another. Both ecosystems provide higher-level pose estimation.
Limelight MegaTag2#
A single AprilTag seen from far away or at an angle can be ambiguous — there are two mathematically valid orientations, and the wrong one throws your pose off badly. Limelight's MegaTag2 (2024+) solves this by assuming you already know the robot's heading (from your gyro) and using it to disambiguate, giving excellent single-tag results at any distance.
The workflow:
- Feed the gyro heading every loop:
LimelightHelpers.SetRobotOrientation("limelight", yawDegrees, 0, 0, 0, 0, 0); - Read the pose estimate:
LimelightHelpers.PoseEstimate mt2 =
LimelightHelpers.getBotPoseEstimate_wpiBlue_MegaTag2("limelight");
For 2024 and beyond, always use the botpose_orb_wpiblue variant (the MegaTag2 helper above) so the result is in the standard blue-origin coordinate system. Each estimate carries a timestamp and a tag count. Reject obviously bad data — for example, ignore updates when tagCount == 0 or when the robot is spinning faster than 720 deg/s (MegaTag2 relies on a trustworthy heading — Limelight's own example rejects updates above 720 deg/s).
PhotonVision PhotonPoseEstimator#
PhotonLib provides PhotonPoseEstimator, which combines all tags visible at one timestamp into a single field-relative pose. You construct it with the AprilTag field layout and the robot-to-camera transform. Each loop you call a strategy method — e.g. estimateCoprocMultiTagPose(result), which combines all visible tags into one solution on the coprocessor — and get an Optional<EstimatedRobotPose> containing the pose and the timestamp. (Older PhotonLib passed a PoseStrategy such as MULTI_TAG_PNP_ON_COPROCESSOR to the constructor and called a generic update(); current PhotonLib uses these per-strategy methods.)
Common ground#
Both tools converge on the same output your robot code wants: a Pose2d (or 3D pose), a timestamp, and a sense of confidence (more/closer tags = more trustworthy). That confidence is the bridge to the final lesson — fusing vision with odometry. Whatever tool you pick, validate it by placing the robot at a known spot on the field and confirming the reported pose matches a tape-measure check.
the part worth keeping
Key takeaways
- MegaTag2 uses your gyro heading to eliminate single-tag ambiguity; feed SetRobotOrientation every loop and read botpose_orb_wpiblue.
- PhotonVision's PhotonPoseEstimator fuses all visible tags (multi-tag PnP) into one timestamped field pose.
- Both produce a Pose2d + timestamp + confidence, and both should be validated against a known field position.
Programming, Controls & SensorsComputer Vision and Pose Estimationlesson 2 of 3
Keep going
Take the quiz+10 XP with an accountMore in Computer Vision and Pose Estimation
where this came from
Sources and corrections
This lesson is AI-assisted: drafted from primary sources, then reviewed and edited by hand. Errors still get through. When one is reported we fix it and write down what changed, in public, in the corrections log.
sources and further reading
- docs.limelightvision.ioLimelight: Robot Localization with MegaTag2
- docs.photonvision.orgPhotonVision: Estimating Field Relative Pose (PhotonPoseEstimator)
clipped to this lesson
Articles that go further on this
The lesson gets you through the topic. These go wider on it, and they read in one sitting.
- 15 min readFRC Odometry and Pose Estimation: Field-Centric Control with WPILibHow an FRC robot tracks its field position with WPILib: wheel odometry vs pose estimation, gyro heading, fusing AprilTag vision, and field-centric driving./blogread it
- 8 min readFRC Vision: Limelight vs PhotonVision and AprilTag TrackingCompare Limelight and PhotonVision for FRC vision: AprilTag tracking, pose estimation with addVisionMeasurement, MegaTag2, latency, calibration, and cost./blogread it
- 20 min readPhotonVision Setup for FRC: Install, Pipelines & AprilTag PosePhotonVision setup for FRC: install it on a Raspberry Pi or Orange Pi coprocessor, build an AprilTag pipeline, run multi-tag pose, and feed swerve odometry./blogread it
answer sheet
Lesson quiz
All 3 right completes the lesson. Miss one and only that question comes back, anything you already answered correctly stays banked.
0 of 3 answered
01What key assumption does Limelight's MegaTag2 make that MegaTag1 does not?
02To use MegaTag2 correctly, what must robot code do each loop before reading the pose estimate?
03In PhotonVision, what does the Coprocessor MultiTag pose strategy do?
Answer every question to submit.
All 51 lessons in Programming, Controls & Sensorsopenclose
01 / prerequisites
02 / foundations-tools-and-first-program
03 / robot-program-and-command-based
04 / motors-and-control
05 / autonomous-trajectories-simulation
06 / sensing-fundamentals
07 / encoders
08 / gyros-imus-orientation
09 / closed-loop-control
10 / vision-pose-estimation
11 / worked-examples-mini-projects
- Not read yet:Mini-Project: A Closed-Loop Elevator with Motion Magic
- Not read yet:Mini-Project: A Velocity-Controlled Shooter on REVLib
- Not read yet:Mini-Project: A Teleop Swerve Drive Subsystem
- Not read yet:Mini-Project: An Autonomous Routine with PathPlanner
- Not read yet:Mini-Project: Vision-Aligned Scoring with Limelight
12 / common-mistakes-troubleshooting
13 / advanced-techniques-case-studies
- Not read yet:State-Space Control and Kalman Filtering
- Not read yet:Log Replay Architecture with AdvantageKit
- Not read yet:Advanced Pose Estimation: Multi-Tag Fusion and Standard Deviations
- Not read yet:Robot Coordination, Alerts, and Operator Feedback
- Not read yet:Case Study: Hardening Software Before an Event