@@ -57,14 +57,11 @@ public void update() {
5757 aprilTagCameraIO .updateInputs (inputs );
5858
5959 robotPose = calculateBestRobotPose ();
60-
6160 logCameraInfo ();
62- if (RobotHardwareStats .isSimulation ())
63- AprilTagCameraConstants .VISION_SIMULATION .update (RobotContainer .POSE_ESTIMATOR .getCurrentOdometryPose ());
6461 }
6562
6663 public boolean hasNewResult () {
67- return (inputs .hasResult && inputs .distanceFromBestTag != 0 ) && isNewTimestamp ();
64+ return (inputs .hasResult && inputs .distanceFromBestTag != Double . POSITIVE_INFINITY ) && isNewTimestamp ();
6865 }
6966
7067 public Pose2d getEstimatedRobotPose () {
@@ -109,7 +106,7 @@ public double getDistanceToBestTagMeters() {
109106 * @return the robot's pose
110107 */
111108 private Pose2d calculateBestRobotPose () {
112- final Rotation2d gyroHeadingAtTimestamp = RobotHardwareStats .isSimulation () ? RobotContainer .SWERVE . getHeading () : PoseEstimator6328 .getInstance ().samplePose (inputs .latestResultTimestampSeconds ).getRotation ();
109+ final Rotation2d gyroHeadingAtTimestamp = RobotHardwareStats .isSimulation () ? RobotContainer .POSE_ESTIMATOR . getCurrentOdometryPose (). getRotation () : PoseEstimator6328 .getInstance ().samplePose (inputs .latestResultTimestampSeconds ).getRotation ();
113110 return calculateAssumedRobotHeadingPose (gyroHeadingAtTimestamp );
114111 }
115112
@@ -134,7 +131,7 @@ private Translation2d getFieldRelativeRobotTranslation(Rotation2d currentHeading
134131 if (bestTagPose == null )
135132 return null ;
136133
137- setProperCameraRotation ();
134+ correctTargetRelativeRotation ();
138135
139136 final Translation2d tagRelativeCameraTranslation = calculateTagRelativeCameraTranslation (currentHeading , bestTagPose );
140137 final Translation2d fieldRelativeRobotPose = getFieldRelativeRobotPose (tagRelativeCameraTranslation , bestTagPose );
@@ -146,7 +143,7 @@ private Translation2d getFieldRelativeRobotTranslation(Rotation2d currentHeading
146143 * When the roll of the camera changes, the target pitch and yaw are also affected.
147144 * This method corrects the yaw and pitch based on the camera's mount position roll.
148145 */
149- private void setProperCameraRotation () {
146+ private void correctTargetRelativeRotation () {
150147 final Translation2d targetRotation = new Translation2d (inputs .bestTargetRelativePitchRadians , inputs .bestTargetRelativeYawRadians );
151148 targetRotation .rotateBy (Rotation2d .fromRadians (robotCenterToCamera .getRotation ().getX ()));
152149 inputs .bestTargetRelativePitchRadians = targetRotation .getX ();
@@ -214,7 +211,7 @@ private void logCameraInfo() {
214211 Logger .processInputs ("Cameras/" + name , inputs );
215212 if (!FieldConstants .TAG_ID_TO_POSE .isEmpty ())
216213 logUsedTags ();
217- if (!inputs .hasResult || inputs .distanceFromBestTag == 0 || robotPose == null ) {
214+ if (!inputs .hasResult || inputs .distanceFromBestTag == Double . POSITIVE_INFINITY || robotPose == null ) {
218215 logEstimatedRobotPose ();
219216 logSolvePNPPose ();
220217 } else {
0 commit comments