Commit | Line | Data |
---|---|---|
9738295a SG |
1 | package org.usfirst.frc.team3501.robot.commands.climber; |
2 | ||
6a363924 | 3 | import org.usfirst.frc.team3501.robot.Robot; |
150f450f | 4 | import org.usfirst.frc.team3501.robot.subsystems.Climber; |
6a363924 | 5 | |
9738295a SG |
6 | import edu.wpi.first.wpilibj.command.Command; |
7 | ||
8 | /** | |
e2e9a7a7 | 9 | * This command runs the winch at a specified speed and time in seconds when the |
c3e1f46b SG |
10 | * button triggering it is pressed. This command also makes the drive train |
11 | * motors run because the winch is controlled by the drive train. | |
e2e9a7a7 SG |
12 | * |
13 | * pre-condition: This command is run by a button in OI. The robot must be | |
14 | * attached to the rope. | |
15 | * | |
16 | * post-condition: Winch motor set to a specified speed for a specified time. | |
9738295a | 17 | * |
b71b71bc SG |
18 | * @param motorVal |
19 | * value range is from -1 to 1 | |
20 | * @param time | |
21 | * in seconds | |
9738295a SG |
22 | * @author shivanighanta |
23 | * | |
24 | */ | |
ad877a7e | 25 | |
9738295a | 26 | public class RunWinch extends Command { |
150f450f CZ |
27 | Climber climber = Robot.getClimber(); |
28 | ||
9738295a SG |
29 | private double time; |
30 | private double motorVal; | |
31 | ||
ad877a7e | 32 | /** |
411129cd | 33 | * See JavaDoc comment in class for details |
ad877a7e | 34 | * |
411129cd SG |
35 | * @param time |
36 | * time in seconds to run the winch | |
37 | * @param motorVal | |
8565f615 | 38 | * value range is from -1 to 1 |
ad877a7e | 39 | */ |
9738295a | 40 | public RunWinch(double time, double motorVal) { |
150f450f | 41 | requires(climber); |
9738295a SG |
42 | this.time = time; |
43 | this.motorVal = motorVal; | |
44 | } | |
45 | ||
46 | @Override | |
47 | protected void initialize() { | |
48 | } | |
49 | ||
50 | @Override | |
51 | protected void execute() { | |
150f450f | 52 | climber.setMotorValues(motorVal); |
9738295a SG |
53 | } |
54 | ||
55 | @Override | |
56 | protected boolean isFinished() { | |
b8791ca4 | 57 | return timeSinceInitialized() >= time; |
9738295a SG |
58 | } |
59 | ||
60 | @Override | |
61 | protected void end() { | |
150f450f | 62 | climber.stop(); |
9738295a SG |
63 | } |
64 | ||
65 | @Override | |
66 | protected void interrupted() { | |
6a363924 | 67 | end(); |
9738295a SG |
68 | } |
69 | } |