Commit | Line | Data |
---|---|---|
44c26e0c SG |
1 | package org.usfirst.frc.team3501.robot.commands.climber; |
2 | ||
44c26e0c | 3 | import org.usfirst.frc.team3501.robot.Robot; |
b8791ca4 | 4 | import org.usfirst.frc.team3501.robot.subsystems.DriveTrain; |
44c26e0c | 5 | |
44c26e0c SG |
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 | |
b8791ca4 SG |
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. | |
44c26e0c | 13 | * |
b8791ca4 SG |
14 | * pre-condition: This command is run by a button in OI. The robot must have |
15 | * completed climbing. | |
44c26e0c SG |
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 | */ | |
b8791ca4 | 26 | public class MaintainClimbedPosition extends Command { |
44c26e0c | 27 | private double time; |
44c26e0c SG |
28 | |
29 | /** | |
30 | * See JavaDoc comment in class for details | |
31 | * | |
32 | * @param time | |
33 | * time in seconds to run the winch | |
44c26e0c | 34 | */ |
b8791ca4 | 35 | public MaintainClimbedPosition(double time) { |
44c26e0c SG |
36 | requires(Robot.getDriveTrain()); |
37 | this.time = time; | |
44c26e0c SG |
38 | } |
39 | ||
40 | @Override | |
41 | protected void initialize() { | |
44c26e0c SG |
42 | } |
43 | ||
44 | @Override | |
45 | protected void execute() { | |
b8791ca4 SG |
46 | Robot.getDriveTrain().setMotorValues(DriveTrain.MAINTAIN_CLIMBED_POSITION, |
47 | DriveTrain.MAINTAIN_CLIMBED_POSITION); | |
44c26e0c SG |
48 | |
49 | } | |
50 | ||
51 | @Override | |
52 | protected boolean isFinished() { | |
b8791ca4 | 53 | return timeSinceInitialized() >= time; |
44c26e0c SG |
54 | } |
55 | ||
56 | @Override | |
57 | protected void end() { | |
58 | Robot.getDriveTrain().stop(); | |
59 | } | |
60 | ||
61 | @Override | |
62 | protected void interrupted() { | |
63 | end(); | |
64 | } | |
65 | } |