2243bc7a88e1912eebcbfb646033f4a341956988
1 package org
.usfirst
.frc3501
.RiceCatRobot
.commands
;
3 import org
.usfirst
.frc3501
.RiceCatRobot
.Robot
;
4 import org
.usfirst
.frc3501
.RiceCatRobot
.subsystems
.DriveTrain
;
6 import edu
.wpi
.first
.wpilibj
.command
.Command
;
8 public class MoveDistance
extends Command
{
10 double distance
, minSpeed
, maxSpeed
;
12 public MoveDistance(double distance
, double minSpeed
, double maxSpeed
) {
13 requires(Robot
.driveTrain
);
14 this.distance
= distance
;
15 this.minSpeed
= minSpeed
;
16 this.maxSpeed
= maxSpeed
;
19 protected void initialize() {
20 Robot
.driveTrain
.resetEncoders();
24 protected void execute() {
25 double speed
= 4 * (minSpeed
- maxSpeed
) *
26 Math
.pow((Robot
.driveTrain
.getAverageSpeed() / distance
- 0.5), 2)
28 Robot
.driveTrain
.setMotorSpeeds(speed
, speed
);
32 protected boolean isFinished() {
33 if (Robot
.driveTrain
.getLeftDistance() > distance
34 && Robot
.driveTrain
.getRightDistance() > distance
)
40 protected void end() {
41 Robot
.driveTrain
.stop();
45 protected void interrupted() {