diff --git a/photon-lib/py/photonlibpy/simulation/photonCameraSim.py b/photon-lib/py/photonlibpy/simulation/photonCameraSim.py index 21449f45d..3aa42190c 100644 --- a/photon-lib/py/photonlibpy/simulation/photonCameraSim.py +++ b/photon-lib/py/photonlibpy/simulation/photonCameraSim.py @@ -36,6 +36,9 @@ class PhotonCameraSim: self, camera: PhotonCamera, props: SimCameraProperties = SimCameraProperties.PERFECT_90DEG(), + tagLayout: AprilTagFieldLayout = AprilTagFieldLayout.loadField( + AprilTagField.kDefaultField + ), minTargetAreaPercent: float | None = None, maxSightRange: meters | None = None, ): @@ -64,7 +67,7 @@ class PhotonCameraSim: self.videoSimProcEnabled: bool = False self.heartbeatCounter: int = 0 self.nextNtEntryTime = wpilib.Timer.getFPGATimestamp() - self.tagLayout = AprilTagFieldLayout.loadField(AprilTagField.kDefaultField) + self.tagLayout = tagLayout self.cam = camera self.prop = props diff --git a/photon-lib/src/main/java/org/photonvision/simulation/PhotonCameraSim.java b/photon-lib/src/main/java/org/photonvision/simulation/PhotonCameraSim.java index d71eecaeb..2bd7cfc78 100644 --- a/photon-lib/src/main/java/org/photonvision/simulation/PhotonCameraSim.java +++ b/photon-lib/src/main/java/org/photonvision/simulation/PhotonCameraSim.java @@ -81,8 +81,7 @@ public class PhotonCameraSim implements AutoCloseable { private double minTargetAreaPercent; private PhotonTargetSortMode sortMode = PhotonTargetSortMode.Largest; - private final AprilTagFieldLayout tagLayout = - AprilTagFieldLayout.loadField(AprilTagFields.kDefaultField); + private final AprilTagFieldLayout tagLayout; // video stream simulation private final CvSource videoSimRaw; @@ -130,8 +129,24 @@ public class PhotonCameraSim implements AutoCloseable { * @param prop Properties of this camera such as FOV and FPS */ public PhotonCameraSim(PhotonCamera camera, SimCameraProperties prop) { + this(camera, prop, AprilTagFieldLayout.loadField(AprilTagFields.kDefaultField)); + } + + /** + * Constructs a handle for simulating {@link PhotonCamera} values. Processing simulated targets + * through this class will change the associated PhotonCamera's results. + * + *
By default, the minimum target area is 100 pixels and there is no maximum sight range.
+ *
+ * @param camera The camera to be simulated
+ * @param prop Properties of this camera such as FOV and FPS
+ * @param tagLayout The {@link AprilTagFieldLayout} used to solve for tag positions.
+ */
+ public PhotonCameraSim(
+ PhotonCamera camera, SimCameraProperties prop, AprilTagFieldLayout tagLayout) {
this.cam = camera;
this.prop = prop;
+ this.tagLayout = tagLayout;
setMinTargetAreaPixels(kDefaultMinAreaPx);
videoSimRaw =
@@ -163,6 +178,30 @@ public class PhotonCameraSim implements AutoCloseable {
SimCameraProperties prop,
double minTargetAreaPercent,
double maxSightRangeMeters) {
+ this(camera, prop, AprilTagFieldLayout.loadField(AprilTagFields.kDefaultField));
+ this.minTargetAreaPercent = minTargetAreaPercent;
+ this.maxSightRangeMeters = maxSightRangeMeters;
+ }
+
+ /**
+ * Constructs a handle for simulating {@link PhotonCamera} values. Processing simulated targets
+ * through this class will change the associated PhotonCamera's results.
+ *
+ * @param camera The camera to be simulated
+ * @param prop Properties of this camera such as FOV and FPS
+ * @param minTargetAreaPercent The minimum percentage(0 - 100) a detected target must take up of
+ * the camera's image to be processed. Match this with your contour filtering settings in the
+ * PhotonVision GUI.
+ * @param maxSightRangeMeters Maximum distance at which the target is illuminated to your camera.
+ * Note that minimum target area of the image is separate from this.
+ * @param tagLayout AprilTag field layout to use for multi-tag estimation
+ */
+ public PhotonCameraSim(
+ PhotonCamera camera,
+ SimCameraProperties prop,
+ double minTargetAreaPercent,
+ double maxSightRangeMeters,
+ AprilTagFieldLayout tagLayout) {
this(camera, prop);
this.minTargetAreaPercent = minTargetAreaPercent;
this.maxSightRangeMeters = maxSightRangeMeters;
diff --git a/photon-lib/src/main/native/cpp/photon/simulation/PhotonCameraSim.cpp b/photon-lib/src/main/native/cpp/photon/simulation/PhotonCameraSim.cpp
index 165fc200a..3ee6aaddf 100644
--- a/photon-lib/src/main/native/cpp/photon/simulation/PhotonCameraSim.cpp
+++ b/photon-lib/src/main/native/cpp/photon/simulation/PhotonCameraSim.cpp
@@ -29,12 +29,19 @@
#include