Delete StopWinch and Climber subsystem, edit javadoc comments
[3501/2017steamworks] / src / org / usfirst / frc / team3501 / robot / commands / climber / RunWinch.java
1 package org.usfirst.frc.team3501.robot.commands.climber;
2
3 import org.usfirst.frc.team3501.robot.Robot;
4
5 import edu.wpi.first.wpilibj.Timer;
6 import edu.wpi.first.wpilibj.command.Command;
7
8 /**
9 * This command runs the winch at a specified speed and time in seconds when the
10 * button triggering it is pressed. This command also runs the drive train.
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.
16 *
17 * @param motorVal
18 * value range is from -1 to 1
19 * @param time
20 * in seconds
21 * @author shivanighanta
22 *
23 */
24
25 public class RunWinch extends Command {
26 Timer timer;
27 private double time;
28 private double motorVal;
29
30 /**
31 * See JavaDoc comment in class for details
32 *
33 * @param time
34 * time in seconds to run the winch
35 * @param motorVal
36 * value range is from -1 to 1
37 */
38 public RunWinch(double time, double motorVal) {
39 requires(Robot.getDriveTrain());
40 this.time = time;
41 this.motorVal = motorVal;
42 }
43
44 @Override
45 protected void initialize() {
46 timer.start();
47 }
48
49 @Override
50 protected void execute() {
51 Robot.getDriveTrain().setMotorValues(motorVal, motorVal);
52
53 }
54
55 @Override
56 protected boolean isFinished() {
57 return timer.get() >= time;
58 }
59
60 @Override
61 protected void end() {
62 Robot.getDriveTrain().stop();
63
64 }
65
66 @Override
67 protected void interrupted() {
68 end();
69 }
70 }