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