]> git.taranathan.com Git - FRC2026.git/commitdiff
Check a pipeline result has targets before using it.
authorArnav495 <arnieincyberland@gmail.com>
Thu, 4 Sep 2025 19:57:03 +0000 (12:57 -0700)
committerArnav495 <arnieincyberland@gmail.com>
Thu, 4 Sep 2025 19:57:03 +0000 (12:57 -0700)
The null check works fine, but produces warnings.

src/main/java/frc/robot/util/Vision/Vision.java

index 9af6c4f567f4c1a020509f77773d12349030d562..0501edb5598c39f526a3a61d3c1e6830e4e23671 100644 (file)
@@ -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;
         }