--- /dev/null
+package org.usfirst.frc.team3501.robot.commands.driving;
+
+import org.usfirst.frc.team3501.robot.Constants.Auton;
+import org.usfirst.frc.team3501.robot.Robot;
+
+import edu.wpi.first.wpilibj.Timer;
+import edu.wpi.first.wpilibj.command.Command;
+
+public class TimeDrive extends Command {
+ Timer timer;
+ double currentTime, targetTime, speed;
+
+ public TimeDrive() {
+ this(Auton.DEFAULT_TIME, Auton.DEFAULT_SPEED);
+ }
+
+ public TimeDrive(double time) {
+ this(time, Auton.DEFAULT_SPEED);
+ }
+
+ public TimeDrive(double time, double speed) {
+ requires(Robot.driveTrain);
+
+ timer = new Timer();
+ this.currentTime = 0;
+ this.targetTime = time;
+ this.speed = speed;
+ }
+
+ @Override
+ protected void initialize() {
+ timer.start();
+ }
+
+ @Override
+ protected void execute() {
+ currentTime = timer.get();
+
+ double output = speed * ((targetTime - currentTime) / (targetTime));
+
+ Robot.driveTrain.setMotorSpeeds(output, output);
+ }
+
+ @Override
+ protected boolean isFinished() {
+ return currentTime >= targetTime;
+ }
+
+ @Override
+ protected void end() {
+ Robot.driveTrain.stop();
+ }
+
+ @Override
+ protected void interrupted() {
+ end();
+ }
+}