| 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.command.Command; |
| 6 | |
| 7 | /*** |
| 8 | * |
| 9 | * Runs the intake continuously when button is pressed, and when button is not |
| 10 | * pressed does not run. |
| 11 | * |
| 12 | * Intended to be run inside a .whileHeld() call on a button in OI |
| 13 | * |
| 14 | * @author Meeta |
| 15 | * |
| 16 | */ |
| 17 | public class RunIntakeContinuous extends Command { |
| 18 | // create setter method for speed, use setSpeed method to do end() by setting |
| 19 | // speed to 0 |
| 20 | |
| 21 | public RunIntakeContinuous() { |
| 22 | requires(Robot.getIntake()); |
| 23 | } |
| 24 | |
| 25 | @Override |
| 26 | protected boolean isFinished() { |
| 27 | return false; |
| 28 | } |
| 29 | |
| 30 | // Called just before this Command runs the first time |
| 31 | @Override |
| 32 | protected void initialize() { |
| 33 | |
| 34 | } |
| 35 | |
| 36 | // Called repeatedly when this Command is scheduled to run |
| 37 | @Override |
| 38 | protected void execute() { |
| 39 | Robot.getIntake().runIntake(); |
| 40 | } |
| 41 | |
| 42 | // Called once after isFinished returns true |
| 43 | @Override |
| 44 | protected void end() { |
| 45 | Robot.getIntake().stopIntake(); |
| 46 | } |
| 47 | |
| 48 | // Called when another command which requires one or more of the same |
| 49 | // subsystems is scheduled to run |
| 50 | @Override |
| 51 | protected void interrupted() { |
| 52 | end(); |
| 53 | } |
| 54 | |
| 55 | } |