Commit | Line | Data |
---|---|---|
f53566b3 HD |
1 | package org.usfirst.frc.team3501.robot.commands.driving; |
2 | ||
3 | import org.usfirst.frc.team3501.robot.Constants.Auton; | |
4 | import org.usfirst.frc.team3501.robot.Robot; | |
5 | ||
f53566b3 HD |
6 | import edu.wpi.first.wpilibj.command.Command; |
7 | ||
8 | public class TimeDrive extends Command { | |
f53566b3 HD |
9 | double currentTime, targetTime, speed; |
10 | ||
11 | public TimeDrive() { | |
12 | this(Auton.DEFAULT_TIME, Auton.DEFAULT_SPEED); | |
13 | } | |
14 | ||
15 | public TimeDrive(double time) { | |
16 | this(time, Auton.DEFAULT_SPEED); | |
17 | } | |
18 | ||
19 | public TimeDrive(double time, double speed) { | |
20 | requires(Robot.driveTrain); | |
21 | ||
67af84eb | 22 | this.setTimeout(time); |
f53566b3 HD |
23 | this.currentTime = 0; |
24 | this.targetTime = time; | |
25 | this.speed = speed; | |
26 | } | |
27 | ||
28 | @Override | |
29 | protected void initialize() { | |
f53566b3 HD |
30 | } |
31 | ||
32 | @Override | |
33 | protected void execute() { | |
67af84eb | 34 | Robot.driveTrain.joystickDrive(speed, 0); |
f53566b3 | 35 | |
f53566b3 HD |
36 | } |
37 | ||
38 | @Override | |
39 | protected boolean isFinished() { | |
67af84eb | 40 | return this.isTimedOut(); |
f53566b3 HD |
41 | } |
42 | ||
43 | @Override | |
44 | protected void end() { | |
45 | Robot.driveTrain.stop(); | |
46 | } | |
47 | ||
48 | @Override | |
49 | protected void interrupted() { | |
50 | end(); | |
51 | } | |
52 | } |