1 package org
.usfirst
.frc
.team3501
.robot
.commands
;
3 import org
.usfirst
.frc
.team3501
.robot
.Robot
;
5 import edu
.wpi
.first
.wpilibj
.Timer
;
6 import edu
.wpi
.first
.wpilibj
.command
.Command
;
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
13 * dependency on subsystems: drivetrain
15 * pre-condition: robot is on
17 * post condition: robot has driven for the specified amount of time
19 public class DriveForTime
extends Command
{
21 private final static double DEFAULT_SPEED
= 0.5;
23 private double seconds
;
27 public DriveForTime(double seconds
, double speed
) {
28 this.seconds
= seconds
;
32 public DriveForTime(double seconds
) {
33 this(seconds
, DEFAULT_SPEED
);
37 protected void initialize() {
41 Robot
.driveTrain
.setMotorSpeeds(speed
, speed
);
45 protected void execute() {
49 protected boolean isFinished() {
50 if (timer
.get() >= seconds
)
56 protected void end() {
57 Robot
.driveTrain
.setMotorSpeeds(0, 0);
61 protected void interrupted() {