From 0fea178ba31352a929f397567e96459b5f1f3438 Mon Sep 17 00:00:00 2001 From: Arnav495 Date: Thu, 4 Sep 2025 12:57:03 -0700 Subject: [PATCH] Check a pipeline result has targets before using it. The null check works fine, but produces warnings. --- src/main/java/frc/robot/util/Vision/Vision.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/java/frc/robot/util/Vision/Vision.java b/src/main/java/frc/robot/util/Vision/Vision.java index 9af6c4f..0501edb 100644 --- a/src/main/java/frc/robot/util/Vision/Vision.java +++ b/src/main/java/frc/robot/util/Vision/Vision.java @@ -600,9 +600,12 @@ public class Vision { // The latest camera results for(PhotonPipelineResult result : inputs.results){ // TODO: This could be improved by averaging all targets instead of only using 1 + + // Continue if the target doesn't exist or it should be ignored + if (!result.hasTargets()) continue; // Gets the best target to use for the calculations PhotonTrackedTarget target = result.getBestTarget(); - // Continue if the target doesn't exist or it should be ignored + // I don't know why this would happen, but keep it in just in case if(target==null){ continue; } -- 2.39.5