|
1 |
| -package com.team1701.lib.cameras; |
| 1 | +package com.team1701.lib.drivers.cameras; |
2 | 2 |
|
3 | 3 | import java.util.ArrayList;
|
4 | 4 | import java.util.stream.DoubleStream;
|
| 5 | +import java.util.stream.IntStream; |
5 | 6 |
|
6 | 7 | import edu.wpi.first.math.geometry.Transform3d;
|
7 | 8 | import org.littletonrobotics.junction.LogTable;
|
8 | 9 | import org.littletonrobotics.junction.inputs.LoggableInputs;
|
9 | 10 | import org.photonvision.simulation.SimCameraProperties;
|
10 | 11 | import org.photonvision.simulation.VisionSystemSim;
|
| 12 | +import org.photonvision.targeting.MultiTargetPNPResults; |
| 13 | +import org.photonvision.targeting.PNPResults; |
11 | 14 | import org.photonvision.targeting.PhotonPipelineResult;
|
12 | 15 | import org.photonvision.targeting.PhotonTrackedTarget;
|
13 | 16 | import org.photonvision.targeting.TargetCorner;
|
@@ -53,6 +56,19 @@ public void toLog(LogTable table) {
|
53 | 56 |
|
54 | 57 | table.put(targetNamespace + "DetectedCorners", detectedCorners);
|
55 | 58 | }
|
| 59 | + |
| 60 | + var multiTagResult = pipelineResult.getMultiTagResult(); |
| 61 | + table.put("MultiTag/PnpResult/IsPresent", multiTagResult.estimatedPose.isPresent); |
| 62 | + table.put("MultiTag/PnpResult/BestPose", multiTagResult.estimatedPose.best); |
| 63 | + table.put("MultiTag/PnpResult/BestPoseReprojectionError", multiTagResult.estimatedPose.bestReprojErr); |
| 64 | + table.put("MultiTag/PnpResult/AltPose", multiTagResult.estimatedPose.alt); |
| 65 | + table.put("MultiTag/PnpResult/AltPoseReprojectionError", multiTagResult.estimatedPose.altReprojErr); |
| 66 | + table.put("MultiTag/PnpResult/Ambiguity", multiTagResult.estimatedPose.ambiguity); |
| 67 | + table.put( |
| 68 | + "MultiTag/TargetIdsUsed", |
| 69 | + multiTagResult.fiducialIDsUsed.stream() |
| 70 | + .mapToInt(Integer::intValue) |
| 71 | + .toArray()); |
56 | 72 | }
|
57 | 73 |
|
58 | 74 | @Override
|
@@ -95,7 +111,21 @@ public void fromLog(LogTable table) {
|
95 | 111 | targets.add(trackedTarget);
|
96 | 112 | }
|
97 | 113 |
|
98 |
| - pipelineResult = new PhotonPipelineResult(latency, targets); |
| 114 | + var multiTagPnpResultPresent = table.get("MultiTag/PnpResult/IsPresent", false); |
| 115 | + var multiTagPnpResult = multiTagPnpResultPresent |
| 116 | + ? new PNPResults( |
| 117 | + table.get("MultiTag/PnpResult/BestPose", new Transform3d()), |
| 118 | + table.get("MultiTag/PnpResult/AltPose", new Transform3d()), |
| 119 | + table.get("MultiTag/PnpResult/Ambiguity", 0.0), |
| 120 | + table.get("MultiTag/PnpResult/BestPoseReprojectionError", 0.0), |
| 121 | + table.get("MultiTag/PnpResult/AltPoseReprojectionError", 0.0)) |
| 122 | + : new PNPResults(); |
| 123 | + var multiTagTargetIdsUsed = IntStream.of(table.get("MultiTag/TargetIdsUsed", new int[] {})) |
| 124 | + .boxed() |
| 125 | + .toList(); |
| 126 | + var multiTargetResult = new MultiTargetPNPResults(multiTagPnpResult, multiTagTargetIdsUsed); |
| 127 | + |
| 128 | + pipelineResult = new PhotonPipelineResult(latency, targets, multiTargetResult); |
99 | 129 | pipelineResult.setTimestampSeconds(timestamp);
|
100 | 130 |
|
101 | 131 | isConnected = table.get("IsConnected", false);
|
|
0 commit comments