-
Notifications
You must be signed in to change notification settings - Fork 291
Closed
Labels
bugSomething isn't workingSomething isn't workingdocumentationAnything relating to https://docs.photonvision.orgAnything relating to https://docs.photonvision.org
Description
In the PhotonLib pose estimation java example, old vision measurements are being ignored and only the most recent measurement from getAllUnreadResults() is being added to the WPILib pose estimator:
-
getEstimatedGlobalPose()method (the issue is in this method):photonvision/photonlib-java-examples/poseest/src/main/java/frc/robot/Vision.java
Lines 86 to 114 in e8efef4
/** * The latest estimated robot pose on the field from vision data. This may be empty. This should * only be called once per loop. * * <p>Also includes updates for the standard deviations, which can (optionally) be retrieved with * {@link getEstimationStdDevs} * * @return An {@link EstimatedRobotPose} with an estimated pose, estimate timestamp, and targets * used for estimation. */ public Optional<EstimatedRobotPose> getEstimatedGlobalPose() { Optional<EstimatedRobotPose> visionEst = Optional.empty(); for (var change : camera.getAllUnreadResults()) { visionEst = photonEstimator.update(change); updateEstimationStdDevs(visionEst, change.getTargets()); if (Robot.isSimulation()) { visionEst.ifPresentOrElse( est -> getSimDebugField() .getObject("VisionEstimation") .setPose(est.estimatedPose.toPose2d()), () -> { getSimDebugField().getObject("VisionEstimation").setPoses(); }); } } return visionEst; } -
SwerveDrivePoseEstimatorvision update call using thegetEstimatedGlobalPose()method:photonvision/photonlib-java-examples/poseest/src/main/java/frc/robot/Robot.java
Lines 64 to 73 in e8efef4
// Correct pose estimate with vision measurements var visionEst = vision.getEstimatedGlobalPose(); visionEst.ifPresent( est -> { // Change our trust in the measurement based on the tags we can see var estStdDevs = vision.getEstimationStdDevs(); drivetrain.addVisionMeasurement( est.estimatedPose.toPose2d(), est.timestampSeconds, estStdDevs); });
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workingdocumentationAnything relating to https://docs.photonvision.orgAnything relating to https://docs.photonvision.org