competition fixes
[3501/2017steamworks] / src / org / usfirst / frc / team3501 / robot / commands / intake / RunIntakeContinuous.java
CommitLineData
e911bc8e
AD
1package org.usfirst.frc.team3501.robot.commands.intake;
2
e52450a4 3import org.usfirst.frc.team3501.robot.Robot;
f74d236d 4import org.usfirst.frc.team3501.robot.subsystems.Intake;
e911bc8e
AD
5
6import edu.wpi.first.wpilibj.command.Command;
7
8/***
9 *
d8c3d26b
AD
10 * Runs the intake continuously when button is pressed, and when button is not
11 * pressed does not run.
e911bc8e 12 *
f407a656
AD
13 * Intended to be run inside a .whileHeld() call on a button in OI
14 *
e911bc8e
AD
15 * @author Meeta
16 *
17 */
18public class RunIntakeContinuous extends Command {
f74d236d
CZ
19 private Intake intake = Robot.getIntake();
20
21 private double previousMotorValue = 0;
22 private double targetMotorValue = intake.INTAKE_SPEED;
e911bc8e
AD
23
24 public RunIntakeContinuous() {
f74d236d 25 requires(intake);
e911bc8e
AD
26 }
27
28 @Override
29 protected boolean isFinished() {
f407a656 30 return false;
e911bc8e
AD
31 }
32
33 // Called just before this Command runs the first time
34 @Override
35 protected void initialize() {
e911bc8e
AD
36 }
37
38 // Called repeatedly when this Command is scheduled to run
39 @Override
40 protected void execute() {
f74d236d
CZ
41 double motorValue = (6 * previousMotorValue + targetMotorValue) / 7;
42 previousMotorValue = motorValue;
43 intake.setSpeed(motorValue);
e911bc8e
AD
44 }
45
46 // Called once after isFinished returns true
47 @Override
48 protected void end() {
f407a656 49 Robot.getIntake().stopIntake();
e911bc8e
AD
50 }
51
52 // Called when another command which requires one or more of the same
53 // subsystems is scheduled to run
54 @Override
55 protected void interrupted() {
56 end();
57 }
58
59}