move commands/command groups to the proper packages
[3501/stronghold-2016] / src / org / usfirst / frc / team3501 / robot / commands / driving / DriveForTime.java
1 package org.usfirst.frc.team3501.robot.commands.driving;
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 drives the robot for the specified time and specified speed. (If
10 * a speed is not specified, a default speed is used
11 *
12 *
13 * dependency on subsystems: drivetrain
14 *
15 * pre-condition: robot is on
16 *
17 * post condition: robot has driven for the specified amount of time
18 */
19 public class DriveForTime extends Command {
20
21 private final static double DEFAULT_SPEED = 0.5;
22 private double speed;
23 private double seconds;
24
25 private Timer timer;
26
27 public DriveForTime(double seconds, double speed) {
28 this.seconds = seconds;
29 this.speed = speed;
30 }
31
32 public DriveForTime(double seconds) {
33 this(seconds, DEFAULT_SPEED);
34 }
35
36 @Override
37 protected void initialize() {
38 timer = new Timer();
39 timer.start();
40
41 Robot.driveTrain.setMotorSpeeds(speed, speed);
42 }
43
44 @Override
45 protected void execute() {
46 }
47
48 @Override
49 protected boolean isFinished() {
50 if (timer.get() >= seconds)
51 return true;
52 return false;
53 }
54
55 @Override
56 protected void end() {
57 Robot.driveTrain.setMotorSpeeds(0, 0);
58 }
59
60 @Override
61 protected void interrupted() {
62 }
63 }