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