Skip to content

Commit

Permalink
Add method to set vision measurement consumer to VisionLocalizer
Browse files Browse the repository at this point in the history
  • Loading branch information
aidnem committed Nov 18, 2024
1 parent df9bd58 commit 87fa4c3
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions vision/src/main/java/coppercore/vision/VisionLocalizer.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
package coppercore.vision;

import edu.wpi.first.apriltag.AprilTagFieldLayout;
import edu.wpi.first.math.VecBuilder;
import edu.wpi.first.math.geometry.Pose3d;
import edu.wpi.first.wpilibj2.command.SubsystemBase;
import java.util.Optional;
import java.util.function.Consumer;
import java.util.function.Supplier;

import org.littletonrobotics.junction.Logger;
import org.photonvision.EstimatedRobotPose;
import org.photonvision.PhotonPoseEstimator;
Expand All @@ -12,11 +15,6 @@
import org.photonvision.simulation.VisionSystemSim;
import org.photonvision.targeting.PhotonPipelineResult;

import edu.wpi.first.apriltag.AprilTagFieldLayout;
import edu.wpi.first.math.VecBuilder;
import edu.wpi.first.math.geometry.Pose3d;
import edu.wpi.first.wpilibj2.command.SubsystemBase;

/** A reliable vision subsystem to be used in any robot project */
public class VisionLocalizer extends SubsystemBase {
CameraWrapper[] cameras;
Expand Down Expand Up @@ -54,12 +52,18 @@ public VisionLocalizer(
cameraParams[i].robotToCamera()));

if (isSim) {
PhotonCameraSim cameraSim = new PhotonCameraSim(cameras[i].getCamera(), cameraParams[i].simCameraProp());
PhotonCameraSim cameraSim =
new PhotonCameraSim(
cameras[i].getCamera(), cameraParams[i].simCameraProp());
visionSim.addCamera(cameraSim, cameraParams[i].robotToCamera());
}
}
}

public void setVisionMeasurementConsumer(Consumer<VisionMeasurement> newVisionMeasurementConsumer) {
visionMeasurementConsumer = newVisionMeasurementConsumer;
}

public void setSimRobotPoseSupplier(Supplier<Pose3d> newSimRobotPoseSupplier) {
simRobotPoseSupplier = newSimRobotPoseSupplier;
}
Expand Down

0 comments on commit 87fa4c3

Please sign in to comment.