Add camera, change to arcade drive, front chooser only, minor driving fixes
[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.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);
23 this.setInterruptible(false);
24
25 this.setTimeout(time);
26 this.speed = speed;
27 }
28
29 @Override
30 protected void initialize() {
31 }
32
33 @Override
34 protected void execute() {
35 Robot.driveTrain.drive(speed, 0);
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 }