generated from wpilibsuite/vendor-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove camera trust zones, make tag layout be taken as a parameter, a…
…dd LayoutUtil with layout loading util previously in CoreVisionConstants, and remove unneeded constants
- Loading branch information
Showing
8 changed files
with
76 additions
and
121 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 3 additions & 3 deletions
6
vision/src/main/java/coppercore/vision/CameraContainerReal.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 0 additions & 1 deletion
1
vision/src/main/java/coppercore/vision/CameraContainerReplay.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package coppercore.vision; | ||
|
||
import edu.wpi.first.math.geometry.Rotation2d; | ||
import edu.wpi.first.math.geometry.Transform3d; | ||
|
||
public record CameraParams( | ||
String name, | ||
int xResolution, | ||
int yResolution, | ||
int fps, | ||
Rotation2d fov, | ||
Transform3d robotToCamera) {} |
65 changes: 8 additions & 57 deletions
65
vision/src/main/java/coppercore/vision/CoreVisionConstants.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,61 +1,12 @@ | ||
package coppercore.vision; | ||
|
||
import coppercore.vision.Camera.CameraTrustZone; | ||
import edu.wpi.first.apriltag.AprilTagFieldLayout; | ||
import edu.wpi.first.math.Matrix; | ||
import edu.wpi.first.math.VecBuilder; | ||
import edu.wpi.first.math.geometry.Rotation2d; | ||
import edu.wpi.first.math.geometry.Transform3d; | ||
import edu.wpi.first.math.numbers.N1; | ||
import edu.wpi.first.math.numbers.N3; | ||
import edu.wpi.first.math.util.Units; | ||
import edu.wpi.first.wpilibj.DriverStation; | ||
import edu.wpi.first.wpilibj.Filesystem; | ||
import java.io.IOException; | ||
import java.util.Collections; | ||
|
||
/** | ||
* Vision constants for coppercore's internal vision constants. Not to be confused with | ||
* VisionConstants, which is likely your robot project's local vision constants that are configured | ||
* per-project. | ||
*/ | ||
public final class CoreVisionConstants { | ||
public static final String tagLayoutName = "Pairs-Only"; | ||
public static final AprilTagFieldLayout fieldLayout = initLayout(tagLayoutName); | ||
|
||
public static final double lowUncertaintyCutoffDistance = 6.5; | ||
|
||
public static final double skewCutoffDistance = 5.8; | ||
public static final double skewCutoffRotation = Units.degreesToRadians(50); | ||
|
||
public static final Matrix<N3, N1> teleopCameraUncertainty = VecBuilder.fill(0.35, 0.35, 3.5); | ||
|
||
public static final Matrix<N3, N1> lowCameraUncertainty = VecBuilder.fill(0.6, 1.0, 4); | ||
|
||
public static final Matrix<N3, N1> highCameraUncertainty = VecBuilder.fill(12.0, 16.0, 40); | ||
|
||
public static final Matrix<N3, N1> driveUncertainty = VecBuilder.fill(0.1, 0.1, 0.1); | ||
|
||
public static record CameraParams( | ||
String name, | ||
int xResolution, | ||
int yResolution, | ||
int fps, | ||
Rotation2d fov, | ||
Transform3d robotToCamera, | ||
CameraTrustZone zone) {} | ||
|
||
private static AprilTagFieldLayout initLayout(String name) { | ||
AprilTagFieldLayout layout; | ||
// AprilTagFieldLayout's constructor throws an IOException, so we must catch it | ||
// in order to initialize our layout as a static constant | ||
try { | ||
layout = | ||
new AprilTagFieldLayout( | ||
Filesystem.getDeployDirectory().getAbsolutePath() | ||
+ "/taglayout/" | ||
+ name | ||
+ ".json"); | ||
} catch (IOException ioe) { | ||
DriverStation.reportWarning( | ||
"Failed to load AprilTag Layout: " + ioe.getLocalizedMessage(), false); | ||
layout = new AprilTagFieldLayout(Collections.emptyList(), 0.0, 0.0); | ||
} | ||
return layout; | ||
} | ||
// TODO: Tune this value | ||
// This value mainly exists so that this file stays named CoreVisionConstants. | ||
public static final double maxAcceptedDistanceMeters = 10.0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package coppercore.vision; | ||
|
||
import edu.wpi.first.apriltag.AprilTagFieldLayout; | ||
import edu.wpi.first.wpilibj.DriverStation; | ||
import edu.wpi.first.wpilibj.Filesystem; | ||
import java.io.IOException; | ||
import java.util.Collections; | ||
|
||
public class LayoutUtil { | ||
public static AprilTagFieldLayout initLayout(String name) { | ||
AprilTagFieldLayout layout; | ||
// AprilTagFieldLayout's constructor throws an IOException, so we must catch it | ||
// in order to initialize our layout as a static constant | ||
try { | ||
layout = | ||
new AprilTagFieldLayout( | ||
Filesystem.getDeployDirectory().getAbsolutePath() | ||
+ "/taglayout/" | ||
+ name | ||
+ ".json"); | ||
} catch (IOException ioe) { | ||
DriverStation.reportWarning( | ||
"Failed to load AprilTag Layout: " + ioe.getLocalizedMessage(), false); | ||
layout = new AprilTagFieldLayout(Collections.emptyList(), 0.0, 0.0); | ||
} | ||
return layout; | ||
} | ||
} |