5452073515b0fb7d719b1d2df15200d682595dcf
[3501/2017steamworks] / src / org / usfirst / frc / team3501 / robot / commands / intake / RunIntake.java
1 package org.usfirst.frc.team3501.robot.commands.intake;
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 *
10 * Starts running the intake for a specific period of time that the user inputs.
11 *
12 * @author Meeta
13 */
14 public class RunIntake extends Command {
15 private double timeToMove;
16 public Timer timer;
17
18 public RunIntake(double timeToMove) {
19 requires(Robot.getIntake());
20 timer = new Timer();
21 this.timeToMove = timeToMove;
22 }
23
24 @Override
25 protected boolean isFinished() {
26 return timer.get() >= timeToMove;
27 }
28
29 // Called just before this Command runs the first time
30 @Override
31 protected void initialize() {
32 timer.start();
33 }
34
35 // Called repeatedly when this Command is scheduled to run
36 @Override
37 protected void execute() {
38 Robot.getIntake().setSpeed(Robot.getIntake().INTAKE_SPEED);
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() {
50 end();
51 }
52 }