commit
[3501/stronghold-2016] / src / org / usfirst / frc / team3501 / robot / commands / driving / TimeDrive.java
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.command.Command;
7
8 public class TimeDrive extends Command {
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
22 this.setTimeout(time);
23 this.currentTime = 0;
24 this.targetTime = time;
25 this.speed = speed;
26 }
27
28 @Override
29 protected void initialize() {
30 }
31
32 @Override
33 protected void execute() {
34 Robot.driveTrain.joystickDrive(speed, 0);
35
36 }
37
38 @Override
39 protected boolean isFinished() {
40 return this.isTimedOut();
41 }
42
43 @Override
44 protected void end() {
45 Robot.driveTrain.stop();
46 }
47
48 @Override
49 protected void interrupted() {
50 end();
51 }
52 }