Skip to content

Commit d5218e1

Browse files
committed
Add some debug prints
1 parent 8d4024b commit d5218e1

File tree

2 files changed

+46
-0
lines changed

2 files changed

+46
-0
lines changed

photon-lib/src/test/java/org/photonvision/PhotonPoseEstimatorTest.java

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -928,4 +928,46 @@ public PhotonPipelineResult getLatestResult() {
928928
return result;
929929
}
930930
}
931+
932+
933+
@Test
934+
public void meme() {
935+
PhotonCameraInjector cameraOne = new PhotonCameraInjector();
936+
937+
List<VisionTargetSim> simTargets =
938+
aprilTags.getTags().stream()
939+
.map((AprilTag x) -> new VisionTargetSim(x.pose, TargetModel.kAprilTag36h11, x.ID))
940+
.toList();
941+
942+
/* Compound Rolled + Pitched + Yaw */
943+
944+
Transform3d compoundTestTransform =
945+
new Transform3d(
946+
-Units.inchesToMeters(12),
947+
-Units.inchesToMeters(11),
948+
3,
949+
new Rotation3d(
950+
Units.degreesToRadians(37), Units.degreesToRadians(6), Units.degreesToRadians(60)));
951+
952+
var estimator =
953+
new PhotonPoseEstimator(
954+
aprilTags, PoseStrategy.CONSTRAINED_SOLVEPNP, compoundTestTransform);
955+
956+
/* this is the real pose of the robot base we test against */
957+
var realPose = new Pose3d(7.3, 4.42, 0, new Rotation3d(0, 0, 2.197));
958+
959+
PhotonCameraSim cameraOneSim =
960+
new PhotonCameraSim(cameraOne, SimCameraProperties.PERFECT_90DEG());
961+
PhotonPipelineResult result =
962+
cameraOneSim.process(
963+
1, realPose.transformBy(estimator.getRobotToCameraTransform()), simTargets);
964+
cameraOneSim.submitProcessedFrame(result);
965+
966+
estimator.addHeadingData(result.getTimestampSeconds(), realPose.getRotation().toRotation2d());
967+
Optional<EstimatedRobotPose> estimatedPose = estimator.update(result, cameraOne.getCameraMatrix(), cameraOne.getDistCoeffs(), Optional.of(new ConstrainedSolvepnpParams(true, 0)));
968+
969+
System.out.println("Ground truth: " + realPose);
970+
971+
System.out.println(estimatedPose);
972+
}
931973
}

photon-targeting/src/main/java/org/photonvision/estimation/VisionEstimation.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,10 @@ public static Optional<PnpResult> estimateRobotPoseConstrainedSolvepnp(
258258

259259
var guess2 = robotPoseSeed.toPose2d();
260260

261+
System.out.println("cameraCal:\n" + cameraCal);
262+
System.out.println("field2points:\n" + field2points);
263+
System.out.println("point_observations:\n" + point_observations);
264+
261265
var ret =
262266
ConstrainedSolvepnpJni.do_optimization(
263267
headingFree,

0 commit comments

Comments
 (0)