Write execute method , wrote initialize method, and emptied end method
[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 timer = new Timer();
20 this.timeToMove = timeToMove;
21 }
22
23 @Override
24 protected boolean isFinished() {
25 return timer.get() >= timeToMove;
26 }
27
28 // Called just before this Command runs the first time
29 @Override
30 protected void initialize() {
31 timer.start();
32 }
33
34 // Called repeatedly when this Command is scheduled to run
35 @Override
36 protected void execute() {
37 Robot.getIntake().setSpeed(Robot.getIntake().INTAKE_SPEED);
38 }
39
40 // Called once after isFinished returns true
41 @Override
42 protected void end() {
43 }
44
45 // Called when another command which requires one or more of the same
46 // subsystems is scheduled to run
47 @Override
48 protected void interrupted() {
49 end();
50 }
51 }