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 makes the drive train
11 * motors run because the winch is controlled by the drive train.
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.
17 *
18 * @author shivanighanta
19 *
20 */
21
22 public class RunWinch extends Command {
23 Timer timer;
24 private double time;
25 private double motorVal;
26
27 /**
28 * See JavaDoc comment in class for details
29 *
30 * @param time
31 * time in seconds to run the winch
32 * @param motorVal
33 * value range is from -1 to 1
34 */
35 public RunWinch(double time, double motorVal) {
36 requires(Robot.getDriveTrain());
37 this.time = time;
38 this.motorVal = motorVal;
39 }
40
41 @Override
42 protected void initialize() {
43 timer.start();
44 }
45
46 @Override
47 protected void execute() {
48 Robot.getDriveTrain().setMotorValues(motorVal, motorVal);
49
50 }
51
52 @Override
53 protected boolean isFinished() {
54 return timer.get() >= time;
55 }
56
57 @Override
58 protected void end() {
59 Robot.getDriveTrain().stop();
60
61 }
62
63 @Override
64 protected void interrupted() {
65 end();
66 }
67 }