PoseEstimate is the primary result type for robot localization. It bundles a WPILib Pose2d with the timestamp, latency, and per-tag details needed to feed WPILib’s SwerveDrivePoseEstimator or DifferentialDrivePoseEstimator.
Retrieving a PoseEstimate
Four static methods onLimelightHelpers return a PoseEstimate:
| Method | Alliance | Algorithm |
|---|---|---|
getBotPoseEstimate_wpiBlue(name) | Blue | MegaTag1 |
getBotPoseEstimate_wpiRed(name) | Red | MegaTag1 |
getBotPoseEstimate_wpiBlue_MegaTag2(name) | Blue | MegaTag2 |
getBotPoseEstimate_wpiRed_MegaTag2(name) | Red | MegaTag2 |
_wpiBlue variants) for new code — the Red-origin variants exist for compatibility.
PoseEstimate fields
WPILib
Pose2d of the robot in the selected alliance coordinate system. Constructed from the [x, y, yaw] components of the raw NT array; z, roll, and pitch are discarded.Capture timestamp in seconds, already adjusted for latency. Pass this directly to
addVisionMeasurement.Computed as
(ntTimestamp / 1_000_000.0) - (latency / 1000.0) where ntTimestamp is the NetworkTables server-side microsecond timestamp captured atomically with the pose array, and latency is the pipeline latency in milliseconds (index 6 of the raw array).Pipeline processing latency in milliseconds. This is the
tl value embedded at index 6 of the raw botpose NT array.Number of AprilTags used to compute this pose estimate. A value of 0 means no valid pose was obtained.
Distance in meters between the two outermost tags that contributed to this estimate. Larger span values indicate a more geometrically constrained — and therefore more reliable — pose.
Average distance in meters from the camera to all contributing tags. Shorter distances produce more accurate estimates.
Average area of contributing tags as a percentage of the image (0–100). Higher values indicate closer or larger tag appearances.
Per-tag detail array. Contains one
RawFiducial entry for each tag that contributed to the pose. Empty (length == 0) if the NT array length did not match the expected layout — treat this as an invalid estimate. See RawFiducial fields below.true if this estimate was produced by the MegaTag2 algorithm (botpose_orb_wpiblue / botpose_orb_wpired), false for MegaTag1.RawFiducial fields
RawFiducial is embedded inside PoseEstimate.rawFiducials. Each entry maps to 7 consecutive values in the raw botpose NT array starting at index 11.
AprilTag ID.
Horizontal offset from the camera’s principal point to the tag center, in degrees. Positive values are to the right.
Vertical offset from the camera’s principal point to the tag center, in degrees. Positive values are upward.
Tag area as a percentage of the image (0–100).
3D distance from the camera lens to the tag center, in meters.
3D distance from the robot origin to the tag center, in meters.
Pose ambiguity ratio for this tag. Values close to 0 are unambiguous; values approaching 1 indicate the solver found two near-equally-plausible poses.
Helper methods
validPoseEstimate
true if pose is non-null, pose.rawFiducials is non-null, and pose.rawFiducials.length > 0. Use this as a quick guard before passing a pose to the estimator.
printPoseEstimate
PoseEstimate fields and the full rawFiducials breakdown to standard output. Useful during debugging. Prints "No PoseEstimate available." if pose is null.