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 | ||
43980ce1 | 5 | import edu.wpi.first.wpilibj.Timer; |
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 |
411129cd | 10 | * button triggering it is pressed. This command also runs 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 | * |
de8c65d3 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 | 25 | public class RunWinch extends Command { |
6a363924 | 26 | Timer timer; |
9738295a SG |
27 | private double time; |
28 | private double motorVal; | |
29 | ||
ad877a7e | 30 | /** |
411129cd | 31 | * See JavaDoc comment in class for details |
ad877a7e | 32 | * |
411129cd SG |
33 | * @param time |
34 | * time in seconds to run the winch | |
35 | * @param motorVal | |
36 | * value range is from -1 to 1 | |
ad877a7e | 37 | */ |
9738295a | 38 | public RunWinch(double time, double motorVal) { |
411129cd | 39 | requires(Robot.getDriveTrain()); |
9738295a SG |
40 | this.time = time; |
41 | this.motorVal = motorVal; | |
42 | } | |
43 | ||
44 | @Override | |
45 | protected void initialize() { | |
6a363924 | 46 | timer.start(); |
9738295a SG |
47 | } |
48 | ||
49 | @Override | |
50 | protected void execute() { | |
411129cd | 51 | Robot.getDriveTrain().setMotorValues(motorVal, motorVal); |
9738295a SG |
52 | |
53 | } | |
54 | ||
55 | @Override | |
56 | protected boolean isFinished() { | |
6a363924 | 57 | return timer.get() >= time; |
9738295a SG |
58 | } |
59 | ||
60 | @Override | |
61 | protected void end() { | |
411129cd SG |
62 | Robot.getDriveTrain().stop(); |
63 | ||
9738295a SG |
64 | } |
65 | ||
66 | @Override | |
67 | protected void interrupted() { | |
6a363924 | 68 | end(); |
9738295a SG |
69 | } |
70 | } |