Skip to content

Commit 8547ee7

Browse files
authored
Resolve TODO comments in MultiPhotonPoseEstimator (#144)
- Update `MultiPhotonPoseEstimator` to use `resetHeadingData(double, Rotation2d)` - Update `PhotonVisionPosePublisher` to implement `AutoCloseable`
1 parent 8232675 commit 8547ee7

3 files changed

Lines changed: 19 additions & 8 deletions

File tree

vision/src/main/java/com/team2813/lib2813/vision/MultiPhotonPoseEstimator.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ private SimCameraProperties createSimProperties() {
226226
public void close() {
227227
photonCamera.close();
228228
cameraPosePublisher.close();
229-
// TODO: Update PhotonVisionPosePublisher to support close() and call it here
229+
robotPosePublisher.close();
230230
}
231231
}
232232

@@ -355,11 +355,8 @@ public void resetHeadingData(double timestampSeconds, Rotation2d heading) {
355355
}
356356

357357
public void resetHeadingData(double timestampSeconds, Rotation3d heading) {
358-
// TODO: Use PhotonPoseEstimator.resetHeadingData(double, Rotation2d) once we use a version of
359-
// PhotonVision that includes it (see https://github.com/PhotonVision/photonvision/pull/2013).
360358
for (PhotonCameraWrapper<C> cameraWrapper : cameraWrappers) {
361-
cameraWrapper.estimator.resetHeadingData(timestampSeconds, heading.toRotation2d());
362-
cameraWrapper.estimator.addHeadingData(timestampSeconds, heading);
359+
cameraWrapper.estimator.resetHeadingData(timestampSeconds, heading);
363360
}
364361
}
365362

vision/src/main/java/com/team2813/lib2813/vision/PhotonVisionPosePublisher.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
*
4242
* @since 2.0.0
4343
*/
44-
public final class PhotonVisionPosePublisher {
44+
public final class PhotonVisionPosePublisher implements AutoCloseable {
4545
/**
4646
* How much time we expect to pass between receiving pose estimates from PhotonVision when an
4747
* AprilTag is visible. Empirically, this is 0.1 seconds.
@@ -105,6 +105,15 @@ public void publish(List<EstimatedRobotPose> poseEstimates) {
105105
aprilTagPosePublisher.publish(aprilTagPoses);
106106
}
107107

108+
/**
109+
* @since 2.1.0
110+
*/
111+
@Override
112+
public void close() {
113+
robotPosePublisher.close();
114+
aprilTagPosePublisher.close();
115+
}
116+
108117
/** Gets the robot pose from the EstimatedRobotPose and converts it to a timestamped value. */
109118
private TimestampedValue<Pose3d> getRobotPoseFromEstimatedRobotPose(
110119
EstimatedRobotPose estimatedRobotPose) {

vision/src/main/java/com/team2813/lib2813/vision/TimestampedStructPublisher.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright 2025 Prospect Robotics SWENext Club
2+
Copyright 2025-2026 Prospect Robotics SWENext Club
33
44
Licensed under the Apache License, Version 2.0 (the "License");
55
you may not use this file except in compliance with the License.
@@ -32,7 +32,7 @@
3232
* data that takes longer to produce than the frequency of the robot's event loop (for example,
3333
* estimated robot pose data produced by a camera).
3434
*/
35-
final class TimestampedStructPublisher<S> {
35+
final class TimestampedStructPublisher<S> implements AutoCloseable {
3636
private static final long MICROS_PER_SECOND = 1_000_000;
3737

3838
/**
@@ -106,6 +106,11 @@ public void publish(List<TimestampedValue<S>> timestampedValues) {
106106
}
107107
}
108108

109+
@Override
110+
public void close() {
111+
publisher.close();
112+
}
113+
109114
private long currentTimeMicros() {
110115
return (long) (fpgaTimestampSupplier.get() * MICROS_PER_SECOND);
111116
}

0 commit comments

Comments
 (0)