Add 'requires' command
[3501/2017steamworks] / src / org / usfirst / frc / team3501 / robot / commands / intake / RunIntake.java
CommitLineData
763ccd44
M
1package org.usfirst.frc.team3501.robot.commands.intake;
2
e0c1a10b 3import org.usfirst.frc.team3501.robot.Robot;
dab6e7d6
AD
4
5import edu.wpi.first.wpilibj.Timer;
763ccd44
M
6import edu.wpi.first.wpilibj.command.Command;
7
8/**
9 *
10 * Starts running the intake for a specific period of time that the user inputs.
e8eb8b46 11 *
763ccd44
M
12 * @author Meeta
13 */
14public class RunIntake extends Command {
e8eb8b46 15 private double timeToMove;
dab6e7d6 16 public Timer timer;
763ccd44 17
e8eb8b46 18 public RunIntake(double timeToMove) {
69322d05 19 requires(Robot.getIntake());
dab6e7d6 20 timer = new Timer();
e8eb8b46 21 this.timeToMove = timeToMove;
763ccd44
M
22 }
23
24 @Override
25 protected boolean isFinished() {
dab6e7d6 26 return timer.get() >= timeToMove;
763ccd44
M
27 }
28
29 // Called just before this Command runs the first time
30 @Override
31 protected void initialize() {
e0c1a10b 32 timer.start();
763ccd44
M
33 }
34
35 // Called repeatedly when this Command is scheduled to run
36 @Override
37 protected void execute() {
e0c1a10b 38 Robot.getIntake().setSpeed(Robot.getIntake().INTAKE_SPEED);
763ccd44
M
39 }
40
41 // Called once after isFinished returns true
42 @Override
43 protected void end() {
44 }
45
46 // Called when another command which requires one or more of the same
47 // subsystems is scheduled to run
48 @Override
49 protected void interrupted() {
dab6e7d6 50 end();
763ccd44
M
51 }
52}