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