Skip to content

Commit e62ffb8

Browse files
committed
Replace timer with encoder to finish climb
1 parent f22edc4 commit e62ffb8

1 file changed

Lines changed: 2 additions & 5 deletions

File tree

  • Robot2019/src/main/java/frc/robot/commands

Robot2019/src/main/java/frc/robot/commands/Climb.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,28 +11,25 @@
1111
import frc.robot.subsystems.Climber;
1212
import frc.robot.subsystems.Drivetrain;
1313
import edu.wpi.first.wpilibj.Joystick;
14-
import edu.wpi.first.wpilibj.Timer;
1514

1615
public class Climb extends Command {
1716
private Climber climber;
1817
private Drivetrain dt;
1918
private Joystick dtJoy;
2019
private State state;
21-
private Timer timer;
2220

2321
private final double backDrive = -0.5; // TODO: Set this to reasonable/tested value;
2422
private final double climbUp = 1;
2523
private final double climbDown = -1;
2624
private final double retract = -1;
2725
private final double overrideThreshold = 0.1; // TODO: Set this to reasonable/tested value;
2826
private final double retractGoal = 0; // TODO: Set this to reasonable/tested value;
29-
private final double startTime = 2; // Time to lift off the floor. TODO: Set this to reasonable/tested value
27+
private final double offGroundHeight = 15; // TODO: Set this to reasonable/tested value;
3028

3129
public Climb(Climber climber, Drivetrain dt, Joystick joy) {
3230
// Use requires() here to declare subsystem dependencies
3331
this.climber = climber;
3432
this.dt = dt;
35-
timer = new Timer();
3633
dtJoy = joy;
3734
requires(climber);
3835
requires(dt);
@@ -107,7 +104,7 @@ protected void interrupted() {
107104
* overriding the climb
108105
*/
109106
private boolean robotOnPlatform() {
110-
return timer.get() > startTime && (dt.isStalled() || Math.abs(dtJoy.getY()) > overrideThreshold);
107+
return (dt.isStalled() && climber.getEncDistance() > offGroundHeight) || Math.abs(dtJoy.getY()) > overrideThreshold;
111108
}
112109

113110
private enum State {

0 commit comments

Comments
 (0)