|
17 | 17 | import edu.wpi.first.math.numbers.N1; |
18 | 18 | import edu.wpi.first.math.numbers.N3; |
19 | 19 | import edu.wpi.first.wpilibj.Alert; |
| 20 | +import edu.wpi.first.wpilibj.DriverStation; |
20 | 21 | import edu.wpi.first.wpilibj.Alert.AlertType; |
| 22 | +import edu.wpi.first.wpilibj2.command.PrintCommand; |
21 | 23 | import edu.wpi.first.wpilibj2.command.SubsystemBase; |
22 | 24 | import frc.robot.subsystems.vision.VisionIO.PoseObservationType; |
23 | 25 | import java.util.LinkedList; |
24 | 26 | import java.util.List; |
25 | 27 | import org.littletonrobotics.junction.Logger; |
| 28 | +import org.w3c.dom.ranges.DocumentRange; |
26 | 29 |
|
27 | 30 | public class Vision extends SubsystemBase { |
28 | 31 | private final VisionConsumer consumer; |
@@ -55,18 +58,13 @@ public Vision(VisionConsumer consumer, VisionIO... io) { |
55 | 58 | * @param cameraIndex The index of the camera to use. |
56 | 59 | */ |
57 | 60 | public Rotation2d getTargetX(int cameraIndex) { |
58 | | - // Add tag poses |
59 | | - //for (int c = 0; c < 2; c++) { |
60 | | - for (int tagId : inputs[0].tagIds) { |
61 | | - // for (int tagId2 : inputs[1].tagIds) { |
62 | | - |
63 | | - var tagPose = aprilTagLayout.getTagPose(tagId); |
64 | | - // if (tagId == cameraIndex) { |
65 | | - // DriverStation.reportWarning(Integer.toString(tagId), false); |
66 | | - return tagPose.get().toPose2d().getRotation(); |
67 | | - //} |
| 61 | + for (int i: inputs[0].tagIds) { |
| 62 | + DriverStation.reportWarning(Integer.toString(i), false); |
| 63 | + var tagPose = aprilTagLayout.getTagPose(i); |
| 64 | + if (i == cameraIndex) { |
| 65 | + return Rotation2d.fromRotations(tagPose.get().getRotation().toRotation2d().getDegrees() * -1 * tagPose.get().getRotation().getX()); |
| 66 | + } |
68 | 67 | } |
69 | | - // } |
70 | 68 | return Rotation2d.kZero; |
71 | 69 | } |
72 | 70 |
|
|
0 commit comments