e9a8f9f34bb598906cdcb4e2b4d8bb90e4b5e612
1 package org
.usfirst
.frc
.team3501
.robot
.commands
.driving
;
3 import org
.usfirst
.frc
.team3501
.robot
.Constants
.Auton
;
4 import org
.usfirst
.frc
.team3501
.robot
.Robot
;
6 import edu
.wpi
.first
.wpilibj
.Timer
;
7 import edu
.wpi
.first
.wpilibj
.command
.Command
;
9 public class TimeDrive
extends Command
{
11 double currentTime
, targetTime
, speed
;
14 this(Auton
.DEFAULT_TIME
, Auton
.DEFAULT_SPEED
);
17 public TimeDrive(double time
) {
18 this(time
, Auton
.DEFAULT_SPEED
);
21 public TimeDrive(double time
, double speed
) {
22 requires(Robot
.driveTrain
);
26 this.targetTime
= time
;
31 protected void initialize() {
36 protected void execute() {
37 currentTime
= timer
.get();
39 double output
= speed
* ((targetTime
- currentTime
) / (targetTime
));
41 Robot
.driveTrain
.setMotorSpeeds(output
, output
);
45 protected boolean isFinished() {
46 return currentTime
>= targetTime
;
50 protected void end() {
51 Robot
.driveTrain
.stop();
55 protected void interrupted() {