1 package org
.usfirst
.frc
.team3501
.robot
.commands
.driving
;
3 import org
.usfirst
.frc
.team3501
.robot
.Constants
;
4 import org
.usfirst
.frc
.team3501
.robot
.Robot
;
6 import edu
.wpi
.first
.wpilibj
.command
.Command
;
9 * This command will move the robot at the specified speed for the specified
12 * post-condition: has driven for the distance and speed specified
14 * @author Meryem and Avi
17 public class DriveDistance
extends Command
{
18 private double maxTimeOut
;
22 public DriveDistance(double distance
, double maxTimeOut
) {
23 requires(Robot
.driveTrain
);
24 this.maxTimeOut
= maxTimeOut
;
25 this.distance
= distance
;
29 protected void initialize() {
30 Robot
.driveTrain
.resetEncoders();
34 protected void execute() {
35 Robot
.driveTrain
.driveDistance(distance
, maxTimeOut
);
40 protected boolean isFinished() {
41 if (timeSinceInitialized() >= maxTimeOut
43 .reachedTarget() || Robot
.driveTrain
.getError() < 1) {
44 System
.out
.println("time: " + timeSinceInitialized());
45 Constants
.DriveTrain
.time
= timeSinceInitialized();
52 protected void end() {
53 Robot
.driveTrain
.disable();
57 protected void interrupted() {