Commit | Line | Data |
---|---|---|
78b997ee ME |
1 | package org.usfirst.frc.team3501.robot.commands.driving; |
2 | ||
3 | import org.usfirst.frc.team3501.robot.Robot; | |
4 | ||
4d1c3598 | 5 | import edu.wpi.first.wpilibj.Timer; |
78b997ee ME |
6 | import edu.wpi.first.wpilibj.command.Command; |
7 | ||
8 | /** | |
9 | * | |
10 | */ | |
11 | public class TimeDrive extends Command { | |
d17d868d | 12 | Timer timer; |
13 | double motorVal, time; | |
14 | ||
15 | public TimeDrive(final double time, final double motorVal) { | |
16 | requires(Robot.getDriveTrain()); | |
17 | ||
18 | timer = new Timer(); | |
19 | this.time = time; | |
20 | this.motorVal = motorVal; | |
21 | } | |
22 | ||
23 | @Override | |
24 | protected void initialize() { | |
25 | timer.start(); | |
26 | Robot.getDriveTrain().setMotorValues(motorVal, motorVal); | |
27 | } | |
28 | ||
29 | @Override | |
30 | protected void execute() { | |
31 | } | |
32 | ||
33 | @Override | |
34 | protected boolean isFinished() { | |
35 | return timer.get() >= time; | |
36 | } | |
37 | ||
38 | @Override | |
39 | protected void end() { | |
40 | Robot.getDriveTrain().stop(); | |
41 | } | |
42 | ||
43 | @Override | |
44 | protected void interrupted() { | |
45 | end(); | |
46 | } | |
78b997ee | 47 | } |