@@ -176,26 +176,6 @@ public Pose2d closestTagPose(double angleOfCoverageInDegrees, double distanceThr
176176 return i == null ? null : kFieldLayout .getTagPose (i ).get ().toPose2d ();
177177 }
178178
179- /**
180- * Finds the {@code Pose2d} of the {@code AprilTag} that is closest (in terms of
181- * angular displacement) to the robot when the specified {@code Translation2d}
182- * is applied to the robot.
183- *
184- * @param translation a {@code Translation2d}
185- * @param distanceThresholdInMeters the maximum distance (in meters) within
186- * which {@code AprilTag}s are considered
187- * @return the {@code Pose2d} of the {@code AprilTag} that is closest (in terms
188- * of angular displacement) to the robot when the specified
189- * {@code Translation2d} is applied to the robot
190- */
191- public Pose2d closestTagPose (Translation2d translation , double distanceThresholdInMeters ) {
192- var pose = getEstimatedPose ();
193- if (translation .getNorm () > 0 )
194- pose = new Pose2d (pose .getTranslation (), translation .getAngle ());
195- var i = closestTagID (pose , distanceThresholdInMeters );
196- return i == null ? null : kFieldLayout .getTagPose (i ).get ().toPose2d ();
197- }
198-
199179 /**
200180 * Determines the ID of the {@code AprilTag} that is closest to the specified
201181 * {@code Pose2d} ({@code null} if no such {@code AprilTag}).
@@ -227,35 +207,6 @@ public static Integer closestTagID(Pose2d pose, double angleOfCoverageInDegrees,
227207 return null ;
228208 }
229209
230- /**
231- * Determines the ID of the {@code AprilTag} that is closest (in terms of
232- * angular displacement) to the specified {@code Pose2d} ({@code null} if no
233- * such {@code AprilTag}).
234- *
235- * @param pose a {@code Pose2d}
236- * @param distanceThresholdInMeters the maximum distance (in meters) within
237- * which {@code AprilTag}s are considered
238- * @return the ID of the {@code AprilTag} that is closest (in terms of angular
239- * displacement) to the specified {@code Pose2d} ({@code null} if no
240- * such {@code AprilTag})
241- */
242- public static Integer closestTagID (Pose2d pose , double distanceThresholdInMeters ) {
243- var s = kFieldLayout .getTags ().stream ()
244- // consider only the tags facing toward the robot
245- .filter (
246- t -> Math .abs (
247- t .pose .getTranslation ().toTranslation2d ().minus (pose .getTranslation ()).getAngle ()
248- .minus (t .pose .toPose2d ().getRotation ()).getDegrees ()) > 90 )
249- .filter (t -> Math .abs (translationalDisplacement (pose , t .pose .toPose2d ())) < distanceThresholdInMeters )
250- // only tags sufficently close
251- .map (t -> Map .entry (t .ID , Math .abs (angularDisplacement (pose , t .pose .toPose2d ()).getDegrees ())));
252- Optional <Entry <Integer , Double >> closest = s .reduce ((e1 , e2 ) -> e1 .getValue () < e2 .getValue () ? e1 : e2 );
253- if (closest .isPresent ()) {
254- return closest .get ().getKey ();
255- } else
256- return null ;
257- }
258-
259210 /**
260211 * Calculates the angular displacement from the estimated {@code Pose2d} of the
261212 * robot to the specified {@code AprilTag}.
@@ -266,7 +217,7 @@ public static Integer closestTagID(Pose2d pose, double distanceThresholdInMeters
266217 */
267218 public Rotation2d angularDisplacement (int tagID ) {
268219 try {
269- return angularDisplacement (this . getEstimatedPose (), kFieldLayout .getTagPose (tagID ).get ().toPose2d ());
220+ return angularDisplacement (getEstimatedPose (), kFieldLayout .getTagPose (tagID ).get ().toPose2d ());
270221 } catch (Exception e ) {
271222 return null ;
272223 }
0 commit comments