11package frc .team2767 .deepspace .command .approach ;
22
33import edu .wpi .first .wpilibj .DriverStation ;
4- import edu .wpi .first .wpilibj .Timer ;
54import edu .wpi .first .wpilibj .command .Command ;
65import edu .wpi .first .wpilibj .smartdashboard .SmartDashboard ;
76import frc .team2767 .deepspace .Robot ;
@@ -21,7 +20,6 @@ public class VisionAutoAlignPickupCommand extends Command {
2120 private static final double MAX_YAW = 0.3 ;
2221 private static final double goodEnoughYaw = 1.5 ;
2322 private static final double DRIVE_EXPO = 0.5 ;
24- private static final double YAW_EXPO = 0.5 ;
2523 private static final double DEADBAND = 0.05 ;
2624 private static final double MIN_RANGE = 35.0 ;
2725 private static final double FWD_SCALE = 0.6 ;
@@ -31,23 +29,18 @@ public class VisionAutoAlignPickupCommand extends Command {
3129 private static final DriveSubsystem DRIVE = Robot .DRIVE ;
3230 private static final VisionSubsystem VISION = Robot .VISION ;
3331 private final ExpoScale driveExpo ;
34- private final ExpoScale yawExpo ;
3532 private final Logger logger = LoggerFactory .getLogger (this .getClass ());
3633 private double range ;
37- private double strafeError ;
38- private double yawError ;
3934 private DriverControls controls ;
4035 private double strafeCorrection ;
4136 private boolean isAuton ;
4237 private double targetYaw ;
4338 private boolean isGood = false ;
4439 private RateLimit strafeRateLimit ;
45- private double last ;
4640
4741 public VisionAutoAlignPickupCommand () {
4842 requires (DRIVE );
4943 this .driveExpo = new ExpoScale (DEADBAND , DRIVE_EXPO );
50- this .yawExpo = new ExpoScale (DEADBAND , YAW_EXPO );
5144 strafeRateLimit = new RateLimit (0.04 ); // 0.015
5245 }
5346
@@ -64,7 +57,6 @@ protected void initialize() {
6457 } else targetYaw = 90.0 ;
6558 DRIVE .setTargetYaw (targetYaw );
6659 logger .info ("Target Yaw: {}" , targetYaw );
67- last = Timer .getFPGATimestamp ();
6860 }
6961
7062 @ SuppressWarnings ("Duplicates" )
@@ -76,7 +68,7 @@ protected void execute() {
7668 isGood = range >= 0 ; // check if range is good (we have a target), not -1
7769
7870 // Calculate Yaw Term based on gyro
79- yawError = targetYaw - Math .IEEEremainder (DRIVE .getGyro ().getAngle (), 360.0 );
71+ double yawError = targetYaw - Math .IEEEremainder (DRIVE .getGyro ().getAngle (), 360.0 );
8072 DRIVE .setYawError (yawError );
8173 double yaw = kP_YAW * yawError ;
8274 if (yaw > MAX_YAW ) yaw = MAX_YAW ;
@@ -96,7 +88,8 @@ protected void execute() {
9688 }
9789
9890 double strafe ;
99- strafeError = Math .sin (Math .toRadians (VISION .getCorrectedBearing ())) * range - strafeCorrection ;
91+ double strafeError =
92+ Math .sin (Math .toRadians (VISION .getCorrectedBearing ())) * range - strafeCorrection ;
10093
10194 VISION .setStrafeError (strafeError );
10295
0 commit comments