add precondition and Timeout to Expel and Intake commands
[3501/stronghold-2016] / src / org / usfirst / frc / team3501 / robot / commands / IntakeBall.java
CommitLineData
898ac295
LM
1package org.usfirst.frc.team3501.robot.commands;
2
2a4a0ca5 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 take a boulder into the robot if there is not a boulder
9 * present inside already.
10 *
a1989c11
LM
11 * pre-condition: Intake arm must be at correct height and a boulder is not
12 * present inside the robot.
d034d78f
LM
13 *
14 * post-condition: A boulder is taken in from the field outside of the robot
15 * into the robot.
16 *
17 * @author Lauren and Niyati
18 *
19 */
20
898ac295 21public class IntakeBall extends Command {
a1989c11 22 private final int TIMEOUT_AMOUNT = 5;
898ac295
LM
23
24 public IntakeBall() {
df77579b 25 requires(Robot.intakeArm);
898ac295
LM
26 }
27
28 @Override
29 protected void initialize() {
a1989c11 30 this.setTimeout(TIMEOUT_AMOUNT);
2a4a0ca5 31 if (!Robot.photogate.isBallPresent())
32 Robot.intakeArm.intakeBall();
898ac295
LM
33
34 }
35
36 @Override
37 protected void execute() {
38
39 }
40
41 @Override
42 protected boolean isFinished() {
a1989c11 43 return (this.isTimedOut() || Robot.photogate.isBallPresent());
898ac295
LM
44 }
45
46 @Override
47 protected void end() {
1828f5f6 48 Robot.intakeArm.stopRollers();
898ac295
LM
49
50 }
51
52 @Override
53 protected void interrupted() {
54
55 }
56
57}