import edu.wpi.first.math.filter.Debouncer;
import edu.wpi.first.math.filter.Debouncer.DebounceType;
+import edu.wpi.first.wpilibj.Timer;
import edu.wpi.first.wpilibj2.command.Command;
import frc.robot.subsystems.hood.Hood;
import frc.robot.subsystems.spindexer.Spindexer;
private Turret turret;
private Hood hood;
- private Debouncer jam_debouncer = new Debouncer(SpindexerConstants.JAM_DEBOUNCE_TIME, DebounceType.kRising); // if their is jam I would think this is 0 -> 1
- private Debouncer reversing_debouncer = new Debouncer(SpindexerConstants.REVERSE_DEBOUNCE_TIME, DebounceType.kFalling); // if there is a release in time Idk what it would be (kfalling vs krising)
+ private Debouncer jam_debouncer = new Debouncer(SpindexerConstants.JAM_DEBOUNCE_TIME, DebounceType.kRising); // if there is jam I would think this is 0 -> 1
private boolean reversing = false;
+ private Timer reverseTimer = new Timer();
public RunSpindexer(Spindexer spindexer, Turret turret, Hood hood) {
this.spindexer = spindexer;
this.turret = turret;
boolean jammed = spindexer.getStatorCurrent() > SpindexerConstants.JAM_CURRENT_THRESHOLD;
if (jam_debouncer.calculate(jammed)) {
reversing = true;
- reversing_debouncer.calculate(reversing);
- // System.out.println("Reversing the spindexer for Anti-Jam");
+ reverseTimer.reset();
+ reverseTimer.start();
}
if (!reversing) {
spindexer.maxSpindexer();
} else {
spindexer.reverseSpindexer();
- if (!reversing_debouncer.calculate(false)) {
+ if (reverseTimer.hasElapsed(SpindexerConstants.REVERSE_DEBOUNCE_TIME)) {
reversing = false;
}
}