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 | ||
6 | import edu.wpi.first.wpilibj.Timer; | |
7 | import edu.wpi.first.wpilibj.command.Command; | |
8 | ||
9 | public class TimeDrive extends Command { | |
10 | Timer timer; | |
11 | double currentTime, targetTime, speed; | |
12 | ||
13 | public TimeDrive() { | |
14 | this(Auton.DEFAULT_TIME, Auton.DEFAULT_SPEED); | |
15 | } | |
16 | ||
17 | public TimeDrive(double time) { | |
18 | this(time, Auton.DEFAULT_SPEED); | |
19 | } | |
20 | ||
21 | public TimeDrive(double time, double speed) { | |
22 | requires(Robot.driveTrain); | |
1b977a14 | 23 | this.setInterruptible(false); |
f53566b3 | 24 | |
1b977a14 | 25 | this.setTimeout(time); |
f53566b3 HD |
26 | this.speed = speed; |
27 | } | |
28 | ||
29 | @Override | |
30 | protected void initialize() { | |
f53566b3 HD |
31 | } |
32 | ||
33 | @Override | |
34 | protected void execute() { | |
1b977a14 | 35 | Robot.driveTrain.drive(speed, 0); |
f53566b3 HD |
36 | } |
37 | ||
38 | @Override | |
39 | protected boolean isFinished() { | |
1b977a14 | 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 | } |