add precondition and Timeout to Expel and Intake commands
[3501/stronghold-2016] / src / org / usfirst / frc / team3501 / robot / commands / ExpelBall.java
CommitLineData
898ac295
LM
1package org.usfirst.frc.team3501.robot.commands;
2
f19a94ad
LM
3import org.usfirst.frc.team3501.robot.Robot;
4
898ac295
LM
5import edu.wpi.first.wpilibj.command.Command;
6
d034d78f
LM
7/***
8 * This command will expel a boulder from the robot, if it is even present to
9 * begin with.
10 *
a1989c11
LM
11 * pre-condition: Intake arm is at correct height and a boulder is present
12 * inside the robot.
d034d78f
LM
13 *
14 * post-condition: A boulder is expelled from inside the robot to the field
15 * outside of the robot.
16 *
17 * @author Lauren and Niyati
18 *
19 */
20
898ac295 21public class ExpelBall extends Command {
a1989c11 22 private final int TIMEOUT_AMOUNT = 5;
898ac295
LM
23
24 public ExpelBall() {
df77579b 25 requires(Robot.intakeArm);
898ac295
LM
26 }
27
28 @Override
29 protected void initialize() {
a1989c11 30 this.setTimeout(TIMEOUT_AMOUNT);
f19a94ad
LM
31 if (Robot.photogate.isBallPresent())
32 Robot.intakeArm.outputBall();
898ac295
LM
33 }
34
35 @Override
36 protected void execute() {
898ac295
LM
37 }
38
39 @Override
40 protected boolean isFinished() {
a1989c11 41 return (this.isTimedOut() || !Robot.photogate.isBallPresent());
898ac295
LM
42 }
43
44 @Override
45 protected void end() {
1828f5f6 46 Robot.intakeArm.stopRollers();
898ac295
LM
47 }
48
49 @Override
50 protected void interrupted() {
51
52 }
53
54}