|
44 | 44 | import org.photonvision.targeting.PnpResult;
|
45 | 45 | import org.photonvision.targeting.TargetCorner;
|
46 | 46 |
|
| 47 | +import com.fasterxml.jackson.core.JsonProcessingException; |
| 48 | +import com.fasterxml.jackson.databind.ObjectMapper; |
| 49 | + |
47 | 50 | public class VisionEstimation {
|
48 | 51 | /** Get the visible {@link AprilTag}s which are in the tag layout using the visible tag IDs. */
|
49 | 52 | public static List<AprilTag> getVisibleLayoutTags(
|
@@ -145,6 +148,18 @@ public static Optional<PnpResult> estimateCamPosePNP(
|
145 | 148 | }
|
146 | 149 | }
|
147 | 150 |
|
| 151 | + private static class DebugData { |
| 152 | + public double[] cameraCal; |
| 153 | + public SimpleMatrix field2points; |
| 154 | + public SimpleMatrix point_observations; |
| 155 | + |
| 156 | + public DebugData(double[] cameraCal, SimpleMatrix field2points, SimpleMatrix point_observations) { |
| 157 | + this.cameraCal = cameraCal; |
| 158 | + this.field2points = field2points; |
| 159 | + this.point_observations = point_observations; |
| 160 | + } |
| 161 | + } |
| 162 | + |
148 | 163 | /**
|
149 | 164 | * Performs constrained solvePNP using 3d-2d point correspondences of visible AprilTags to
|
150 | 165 | * estimate the field-to-camera transformation.
|
@@ -258,9 +273,15 @@ public static Optional<PnpResult> estimateRobotPoseConstrainedSolvepnp(
|
258 | 273 |
|
259 | 274 | var guess2 = robotPoseSeed.toPose2d();
|
260 | 275 |
|
261 |
| - System.out.println("cameraCal:\n" + cameraCal); |
262 |
| - System.out.println("field2points:\n" + field2points); |
263 |
| - System.out.println("point_observations:\n" + point_observations); |
| 276 | + |
| 277 | + // Replace the println statements with: |
| 278 | + var debugData = new DebugData(cameraCal, field2points, point_observations); |
| 279 | + try { |
| 280 | + ObjectMapper mapper = new ObjectMapper(); |
| 281 | + System.out.println(mapper.writeValueAsString(debugData)); |
| 282 | + } catch (JsonProcessingException e) { |
| 283 | + System.err.println("Failed to serialize debug data: " + e.getMessage()); |
| 284 | + } |
264 | 285 |
|
265 | 286 | var ret =
|
266 | 287 | ConstrainedSolvepnpJni.do_optimization(
|
|
0 commit comments