From: Arnav495 Date: Thu, 4 Sep 2025 19:57:03 +0000 (-0700) Subject: Check a pipeline result has targets before using it. X-Git-Url: https://git.taranathan.com/?a=commitdiff_plain;h=0fea178ba31352a929f397567e96459b5f1f3438;p=FRC2026.git Check a pipeline result has targets before using it. The null check works fine, but produces warnings. --- 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; }