Skip to content
Hive Vision

Use it in your code

Call the same targeting and tip-check helpers the Hive Tags dashboard uses, from your own OpMode

The dashboard works out which cluster is scorable, which one to target and whether a cell has tipped. Your OpMode can ask for the same answers: take the detections from the camera, then call the helpers in AprilTagTargeting.

AprilTagConfig config = new AprilTagConfig();
List<AprilTagDetection> detections = aprilTag.getDetections(); // webcam
// Limelight: LimelightBridge.toDetections(limelight.getLatestResult(), config);
AprilTagDetection target = AprilTagTargeting.bestTarget(detections, config);
if (target == null) {
telemetry.addLine(AprilTagTargeting.noTargetReason(detections, config));
} else {
telemetry.addData("range in", target.ftcPose.range);
}

Each is a static method on AprilTagTargeting and takes the detections plus your config:

Method Returns
isScorable true when that detection passes the targeting rules
bestTarget The closest scorable detection, or null
noTargetReason One line saying why nothing is scorable

The tip check reads the nearest cell’s pitch — the same call the dashboard makes:

AprilTagDetection nearest = null;
for (AprilTagDetection d : detections) {
if (d.ftcPose != null && (nearest == null || d.ftcPose.range < nearest.ftcPose.range)) {
nearest = d;
}
}
boolean tipped = nearest != null && AprilTagConfig.isTipped(
nearest.ftcPose.pitch,
config.hiveBaselinePitchDeg,
config.hiveTippedThresholdDeg);

isTipped is Math.abs(pitch - baseline) > threshold, and returns false when there is no pose. hiveBaselinePitchDeg and hiveTippedThresholdDeg are plain fields on AprilTagConfig, so your code and the dashboard read and write the same values. Every detection carries ftcPose.range, ftcPose.pitch and ftcPose.roll — the numbers the rules run on.