Commit | Line | Data |
---|---|---|
f43a1c52 CZ |
1 | package org.usfirst.frc.team3501.robot.commands.intake; |
2 | ||
6486f405 | 3 | import org.usfirst.frc.team3501.robot.Robot; |
f74d236d | 4 | import org.usfirst.frc.team3501.robot.subsystems.Intake; |
6486f405 | 5 | |
f43a1c52 CZ |
6 | import edu.wpi.first.wpilibj.command.Command; |
7 | ||
8 | /** | |
9 | * Reverses the intake until the button triggering this command is released | |
10 | * | |
2a9dabb1 CZ |
11 | * pre-condition: This command must be run by a button in OI with |
12 | * button.whileHeld(...). | |
f43a1c52 CZ |
13 | */ |
14 | public class ReverseIntakeContinuous extends Command { | |
f74d236d CZ |
15 | private Intake intake = Robot.getIntake(); |
16 | ||
17 | private double previousMotorValue = 0; | |
18 | private double targetMotorValue = intake.REVERSE_SPEED; | |
f43a1c52 | 19 | |
6486f405 | 20 | public ReverseIntakeContinuous() { |
f74d236d | 21 | requires(intake); |
f43a1c52 CZ |
22 | } |
23 | ||
24 | // Called just before this Command runs the first time | |
25 | @Override | |
26 | protected void initialize() { | |
27 | } | |
28 | ||
29 | // Called repeatedly when this Command is scheduled to run | |
30 | @Override | |
31 | protected void execute() { | |
f74d236d CZ |
32 | double motorValue = (6 * previousMotorValue + targetMotorValue) / 7; |
33 | previousMotorValue = motorValue; | |
34 | intake.setSpeed(motorValue); | |
f43a1c52 CZ |
35 | } |
36 | ||
37 | // Make this return true when this Command no longer needs to run execute() | |
38 | @Override | |
39 | protected boolean isFinished() { | |
40 | return false; | |
41 | } | |
42 | ||
43 | // Called once after isFinished returns true | |
44 | @Override | |
45 | protected void end() { | |
f74d236d | 46 | intake.stopIntake(); |
f43a1c52 CZ |
47 | } |
48 | ||
49 | // Called when another command which requires one or more of the same | |
50 | // subsystems is scheduled to run | |
51 | @Override | |
52 | protected void interrupted() { | |
5690f629 | 53 | end(); |
f43a1c52 CZ |
54 | } |
55 | } |