*/
public static final double MAX_DISTANCE = 6;
- /** If vision should use manual calculations */
- public static final boolean USE_MANUAL_CALCULATIONS = false; // changed from true for gyro bias correction feature
+ /** If vision should use manual calculations (yawFunction-based vs referencePose-based). Changed to false to support gyro bias correction. */
+ public static final boolean USE_MANUAL_CALCULATIONS = false;
// <ol start="0"> did not work
/**
}
if (VisionConstants.ENABLED) {
+ recordGyroReading(gyroInputs.yawPosition.getRadians());
+
if (vision != null && visionEnabled && visionEnableTimer.hasElapsed(5)) {
- vision.updateOdometry(poseEstimator, time -> getPoseAt(time).getRotation().getRadians(), slipped);
+ ArrayList<EstimatedRobotPose> visionPoses = vision.updateOdometry(poseEstimator, time -> getPoseAt(time).getRotation().getRadians(), slipped);
if (vision.canSeeTag()) {
slipped = false;
modulePoses.reset();
- // record reading for timestamp interpolation
- recordGyroReading(gyroInputs.yawPosition.getRadians());
-
double currentGyroYaw = gyroInputs.yawPosition.getRadians();
- // calculate bias between vision-derived and gyro yaw
- // this compensates for gyro drift over time
- ArrayList<EstimatedRobotPose> visionPoses = vision.getEstimatedPoses(getPose());
-
for (EstimatedRobotPose visionPose : visionPoses) {
if (visionPose.estimatedPose != null && visionPose.timestampSeconds > 0) {
// get yaw from the vision pose estimate
return 0.0;
}
- // use weighted average if we have enough weight, otherwise use EMA
- double avgBias;
- if (totalWeight >= GyroBiasConstants.MIN_TOTAL_WEIGHT) {
- avgBias = weightedBiasSum / totalWeight;
- } else {
- avgBias = emaBias;
- }
+ // use weighted average
+ double avgBias = weightedBiasSum / totalWeight;
// reset
weightedBiasSum = 0.0;
* @param poseEstimator The pose estimator to update
* @param yawFunction A function that returns the yaw as a double given the timestamp
* @param slipped True if the wheels have slipped, false otherwise
+ * @return The list of estimated robot poses from vision
*/
- public void updateOdometry(SwerveDrivePoseEstimator poseEstimator, DoubleUnaryOperator yawFunction, boolean slipped){
+ public ArrayList<EstimatedRobotPose> updateOdometry(SwerveDrivePoseEstimator poseEstimator, DoubleUnaryOperator yawFunction, boolean slipped){
// Simulate vision
// 2 ifs to avoid warning
if(VisionConstants.ENABLED_SIM){
);
sawTag = true;
}
+ return estimatedPoses;
}
/**