1 package org
.usfirst
.frc3501
.RiceCatRobot
.commands
;
3 import org
.usfirst
.frc3501
.RiceCatRobot
.Robot
;
4 import org
.usfirst
.frc3501
.RiceCatRobot
.RobotMap
.Direction
;
6 import edu
.wpi
.first
.wpilibj
.Timer
;
7 import edu
.wpi
.first
.wpilibj
.command
.Command
;
10 * This command takes a time in seconds which is how long it should run
13 public class DriveForTime
extends Command
{
14 private double seconds
;
19 * Drive at a fixed speed (speed) for a fixed time (seconds).
22 * the number of seconds to drive
24 * a motor value in the range [-1, 1]. Negative numbers are
25 * interpreted as driving backwards. 0 is stopped.
27 public DriveForTime(double seconds
, double speed
) {
28 this.seconds
= seconds
;
29 this.speed
= -speed
; // note: setMotorSpeeds(-1, -1) would be
30 // forward full speed, so we take the opposite
31 // of the input to achieve this.
35 protected void initialize() {
36 this.setTimeout(seconds
);
37 Robot
.driveTrain
.setMotorSpeeds(speed
, speed
);
41 protected void execute() {
42 // nothing here because motors are already set
46 protected boolean isFinished() {
47 return this.isTimedOut();
51 protected void end() {
52 Robot
.driveTrain
.stop();
56 protected void interrupted() {