Finish implementing MaintainClimbedPosition
[3501/2017steamworks] / src / org / usfirst / frc / team3501 / robot / commands / climber / MaintainClimbedPosition.java
1 package org.usfirst.frc.team3501.robot.commands.climber;
2
3 import org.usfirst.frc.team3501.robot.Robot;
4 import org.usfirst.frc.team3501.robot.subsystems.DriveTrain;
5
6 import edu.wpi.first.wpilibj.command.Command;
7
8 /**
9 * This command runs the winch at a specified speed and time in seconds when the
10 * robot has completed the climb and when the button triggering it is pressed.
11 * This command also makes the drive train motors run because the winch is
12 * controlled by the drive train.
13 *
14 * pre-condition: This command is run by a button in OI. The robot must have
15 * completed climbing.
16 *
17 * post-condition: Winch motor set to a specified speed for a specified time.
18 *
19 * @param motorVal
20 * value range is from -1 to 1
21 * @param time
22 * in seconds
23 * @author shivanighanta
24 *
25 */
26 public class MaintainClimbedPosition extends Command {
27 private double time;
28
29 /**
30 * See JavaDoc comment in class for details
31 *
32 * @param time
33 * time in seconds to run the winch
34 */
35 public MaintainClimbedPosition(double time) {
36 requires(Robot.getDriveTrain());
37 this.time = time;
38 }
39
40 @Override
41 protected void initialize() {
42 }
43
44 @Override
45 protected void execute() {
46 Robot.getDriveTrain().setMotorValues(DriveTrain.MAINTAIN_CLIMBED_POSITION,
47 DriveTrain.MAINTAIN_CLIMBED_POSITION);
48
49 }
50
51 @Override
52 protected boolean isFinished() {
53 return timeSinceInitialized() >= time;
54 }
55
56 @Override
57 protected void end() {
58 Robot.getDriveTrain().stop();
59 }
60
61 @Override
62 protected void interrupted() {
63 end();
64 }
65 }