Edited comments
[3501/2017steamworks] / src / org / usfirst / frc / team3501 / robot / commands / climber / RunWinch.java
CommitLineData
9738295a
SG
1package org.usfirst.frc.team3501.robot.commands.climber;
2
6a363924
SG
3import org.usfirst.frc.team3501.robot.Robot;
4
43980ce1 5import edu.wpi.first.wpilibj.Timer;
9738295a
SG
6import edu.wpi.first.wpilibj.command.Command;
7
8/**
e2e9a7a7
SG
9 * This command runs the winch at a specified speed and time in seconds when the
10 * button triggering it is pressed.
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 */
24public class RunWinch extends Command {
6a363924 25 Timer timer;
9738295a
SG
26 private double time;
27 private double motorVal;
28
29 public RunWinch(double time, double motorVal) {
6a363924 30 requires(Robot.getClimber());
9738295a
SG
31 this.time = time;
32 this.motorVal = motorVal;
33 }
34
35 @Override
36 protected void initialize() {
6a363924 37 timer.start();
cf086549 38 Robot.getClimber().setMotorValue(motorVal);
9738295a
SG
39 }
40
41 @Override
42 protected void execute() {
43
44 }
45
46 @Override
47 protected boolean isFinished() {
6a363924 48 return timer.get() >= time;
9738295a
SG
49 }
50
51 @Override
52 protected void end() {
6a363924 53 Robot.getClimber().stop();
9738295a
SG
54 }
55
56 @Override
57 protected void interrupted() {
6a363924 58 end();
9738295a
SG
59 }
60}