fill in code
[3501/2017steamworks] / src / org / usfirst / frc / team3501 / robot / commands / intake / ReverseIntake.java
CommitLineData
f43a1c52
CZ
1package org.usfirst.frc.team3501.robot.commands.intake;
2
2cbf20d2
AD
3import org.usfirst.frc.team3501.robot.Robot;
4
9db1440b 5import edu.wpi.first.wpilibj.Timer;
f43a1c52
CZ
6import edu.wpi.first.wpilibj.command.Command;
7
8/**
9 * Reverses the intake roller for a specified amount of time in seconds
10 *
11 * parameters: time to run intake
12 */
13public class ReverseIntake extends Command {
9db1440b
AD
14 private double timeToMove;
15 public Timer timer;
f43a1c52
CZ
16
17 public ReverseIntake(double timeToMove) {
2cbf20d2 18 requires(Robot.getIntake());
9db1440b
AD
19 timer = new Timer();
20 this.timeToMove = timeToMove;
f43a1c52
CZ
21 }
22
23 // Called just before this Command runs the first time
24 @Override
25 protected void initialize() {
9db1440b 26 timer.start();
f43a1c52
CZ
27 }
28
29 // Called repeatedly when this Command is scheduled to run
30 @Override
31 protected void execute() {
9db1440b 32 Robot.getIntake().runReverseIntake();
f43a1c52
CZ
33 }
34
35 // Make this return true when this Command no longer needs to run execute()
36 @Override
37 protected boolean isFinished() {
9db1440b 38 return timer.get() >= timeToMove;
f43a1c52
CZ
39 }
40
41 // Called once after isFinished returns true
42 @Override
43 protected void end() {
9db1440b 44 Robot.getIntake().stopIntake();
f43a1c52
CZ
45 }
46
47 // Called when another command which requires one or more of the same
48 // subsystems is scheduled to run
49 @Override
50 protected void interrupted() {
9db1440b 51 end();
f43a1c52
CZ
52 }
53}