Skip to content

Commit 5556c7c

Browse files
author
He
committed
Add timer to differentiate between climb levels
1 parent 4f6a740 commit 5556c7c

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

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

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,24 +11,28 @@
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;
1415

1516
public class Climb extends Command {
1617
private Climber climber;
1718
private Drivetrain dt;
1819
private Joystick dtJoy;
1920
private State state;
21+
private Timer timer;
2022

2123
private final double backDrive = -0.5; // TODO: Set this to reasonable/tested value;
2224
private final double climbUp = 1;
2325
private final double climbDown = -1;
2426
private final double retract = -1;
2527
private final double overrideThreshold = 0.1; // TODO: Set this to reasonable/tested value;
2628
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
2730

2831
public Climb(Climber climber, Drivetrain dt, Joystick joy) {
2932
// Use requires() here to declare subsystem dependencies
3033
this.climber = climber;
3134
this.dt = dt;
35+
timer = new Timer();
3236
dtJoy = joy;
3337
requires(climber);
3438
requires(dt);
@@ -39,6 +43,7 @@ public Climb(Climber climber, Drivetrain dt, Joystick joy) {
3943
protected void initialize() {
4044
state = State.CLIMBING;
4145
climber.resetEncoder();
46+
timer.reset();
4247
}
4348

4449
// Called repeatedly when this Command is scheduled to run
@@ -102,7 +107,7 @@ protected void interrupted() {
102107
* overriding the climb
103108
*/
104109
private boolean robotOnPlatform() {
105-
return dt.isStalled() || Math.abs(dtJoy.getY()) > overrideThreshold;
110+
return timer.get() > startTime && (dt.isStalled() || Math.abs(dtJoy.getY()) > overrideThreshold);
106111
}
107112

108113
private enum State {

0 commit comments

Comments
 (0)