1 package org
.usfirst
.frc3501
.RiceCatRobot
.commands
;
3 import org
.usfirst
.frc3501
.RiceCatRobot
.Robot
;
4 import org
.usfirst
.frc3501
.RiceCatRobot
.RobotMap
.Direction
;
5 import org
.usfirst
.frc3501
.RiceCatRobot
.subsystems
.DriveTrain
;
7 import edu
.wpi
.first
.wpilibj
.Timer
;
8 import edu
.wpi
.first
.wpilibj
.command
.Command
;
11 * This command will drive the specified distance at specified speed.
14 public class SmoothAccelerateForDistance
extends Command
{
15 private double distance
; // in units of cm
18 public SmoothAccelerateForDistance(double distance
, double speed
) {
19 // Since negative values in setMotorSpeeds(...) are forwards, we reverse
20 // speed here so positive input values will move the robot forwards.
23 // ensure distance is positive
24 this.distance
= Math
.max(distance
, -distance
);
28 protected void initialize() {
29 Robot
.driveTrain
.resetEncoders();
30 Robot
.driveTrain
.setMotorSpeeds(speed
, speed
);
34 protected void execute() {
35 // nothing to do since motor speeds already set
39 protected boolean isFinished() {
40 return Math
.abs(Robot
.driveTrain
.getLeftDistance()) >= distance
41 && Math
.abs(Robot
.driveTrain
.getRightDistance()) >= distance
;
45 protected void end() {
46 Robot
.driveTrain
.stop();
50 protected void interrupted() {