Skip to content

Commit

Permalink
unnest conditionals and add constants
Browse files Browse the repository at this point in the history
  • Loading branch information
linglejack06 committed Dec 3, 2024
1 parent dd69da8 commit 28a704a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
13 changes: 6 additions & 7 deletions vision/src/main/java/coppercore/vision/Camera.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,15 @@ public Matrix<N3, N1> getLatestVariance() {

if (numTags == 0) {
return stdDev;
} else {
if (numTags > 1) {
} else if (numTags > 1) {
stdDev = CoreVisionConstants.multiTagStdDev;
} else if (numTags == 1 && avgDistanceFromTarget > 4) {
} else if (numTags == 1 && avgDistanceFromTarget > CoreVisionConstants.singleTagDistanceCutoff) {
return CoreVisionConstants.rejectionStdDev;
}

// distance based variance
stdDev = stdDev.times(1 + (Math.pow(avgDistanceFromTarget, 2) / 30));
}

// distance based variance
stdDev = stdDev.times(1 + (Math.pow(avgDistanceFromTarget, 2) / CoreVisionConstants.distanceFactor));

return stdDev;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,6 @@ public final class CoreVisionConstants {
public static final Matrix<N3, N1> multiTagStdDev = VecBuilder.fill(0.5, 0.5, 0.5);
public static final Matrix<N3, N1> rejectionStdDev =
VecBuilder.fill(Double.MAX_VALUE, Double.MAX_VALUE, Double.MAX_VALUE);
public static final double singleTagDistanceCutoff = 4.0;
public static final double distanceFactor = 30.0;
}

0 comments on commit 28a704a

Please sign in to comment.