Skip to content

Commit

Permalink
feat: Delay testing the encoder
Browse files Browse the repository at this point in the history
  • Loading branch information
msoucy committed Feb 16, 2025
1 parent cf62c06 commit 79d84ba
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/main/java/frc/robot/subsystems/Elevator.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import org.littletonrobotics.junction.Logger;

import com.chopshop166.chopshoplib.PersistenceCheck;
import com.chopshop166.chopshoplib.boxes.GenericBox;
import com.chopshop166.chopshoplib.logging.LoggedSubsystem;

import edu.wpi.first.math.controller.ProfiledPIDController;
Expand All @@ -24,6 +25,7 @@ public class Elevator extends LoggedSubsystem<Data, ElevatorMap> {
final double SLOW_DOWN_COEF = 0.5;
final double LOWER_SPEED = -0.15;
final double ZEROING_SPEED = -0.1;
final int ZEROING_DELAY = 5;
double holdHeight = 0;

NetworkTableInstance instance = NetworkTableInstance.getDefault();
Expand Down Expand Up @@ -55,11 +57,15 @@ public Command move(DoubleSupplier liftSpeed) {
}

public Command zero() {
return startSafe(() -> {
final GenericBox<Integer> box = new GenericBox<>(0);
return runOnce(() -> {
getMap().motor.resetValidators();
level = ElevatorPresets.OFF;
getData().motor.setpoint = ZEROING_SPEED;
}).until(() -> getMap().motor.validate()).andThen(resetCmd());
box.accept(0);
}).andThen(run(() -> {
box.accept(box.get() + 1);
}).until(() -> box.get() > ZEROING_DELAY && getMap().motor.errored())).andThen(safeStateCmd(), resetCmd());
}

public Command moveToZero() {
Expand Down

0 comments on commit 79d84ba

Please sign in to comment.