c44590af9252fa629476a28b7a8c7c8a9a0bbaf1
[3501/stronghold-2016] / src / org / usfirst / frc / team3501 / robot / commands / DriveForTime.java
1 package org.usfirst.frc.team3501.robot.commands;
2
3 import org.usfirst.frc.team3501.robot.Robot;
4
5 import edu.wpi.first.wpilibj.Timer;
6 import edu.wpi.first.wpilibj.command.Command;
7
8 /**
9 * This command
10 */
11 public class DriveForTime extends Command {
12
13 private final static double DEFAULT_SPEED = 0.5;
14 private double speed;
15 private double seconds;
16
17 private Timer timer;
18
19 public DriveForTime(double seconds, double speed) {
20 this.seconds = seconds;
21 this.speed = speed;
22 }
23
24 public DriveForTime(double seconds) {
25 this(seconds, DEFAULT_SPEED);
26 }
27
28 @Override
29 protected void initialize() {
30 timer = new Timer();
31 timer.start();
32
33 Robot.driveTrain.setMotorSpeeds(speed, speed);
34 }
35
36 @Override
37 protected void execute() {
38 }
39
40 @Override
41 protected boolean isFinished() {
42 if (timer.get() >= seconds)
43 return true;
44 return false;
45 }
46
47 @Override
48 protected void end() {
49 Robot.driveTrain.setMotorSpeeds(0, 0);
50 }
51
52 @Override
53 protected void interrupted() {
54 }
55 }