Edit 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 com.sun.glass.ui.Timer;
6
7 import edu.wpi.first.wpilibj.command.Command;
8
9 /**
10 * This command runs the winch for a given motor value and time in seconds
11 *
12 * @param motorVal
13 * value range is from -1 to 1
14 * @param time
15 * in seconds
16 * @author shivanighanta
17 *
18 */
19 public class RunWinch extends Command {
20 Timer timer;
21 private double time;
22 private double motorVal;
23
24 public RunWinch(double time, double motorVal) {
25 requires(Robot.getClimber());
26 this.time = time;
27 this.motorVal = motorVal;
28 }
29
30 @Override
31 protected void initialize() {
32 timer.start();
33 Robot.getClimber().setMotorValue(motorVal);
34 }
35
36 @Override
37 protected void execute() {
38
39 }
40
41 @Override
42 protected boolean isFinished() {
43 return timer.get() >= time;
44 }
45
46 @Override
47 protected void end() {
48 Robot.getClimber().stop();
49 }
50
51 @Override
52 protected void interrupted() {
53 end();
54 }
55 }