X-Git-Url: http://challenge-bot.com/repos/?a=blobdiff_plain;f=src%2Forg%2Fusfirst%2Ffrc3501%2FRiceCatRobot%2Fcommands%2FDriveFor.java;h=e2473538094e9aa233c946b99f00c017e8763669;hb=e3bfff965c6d5a25b0d98b12b73fbf7eed623326;hp=6e61e616bd0bf16d4b09942224edef3c73908be4;hpb=b5f932ecccf219b28cbebf44c8896347621f6364;p=3501%2F2015-FRC-Spark diff --git a/src/org/usfirst/frc3501/RiceCatRobot/commands/DriveFor.java b/src/org/usfirst/frc3501/RiceCatRobot/commands/DriveFor.java index 6e61e61..e247353 100644 --- a/src/org/usfirst/frc3501/RiceCatRobot/commands/DriveFor.java +++ b/src/org/usfirst/frc3501/RiceCatRobot/commands/DriveFor.java @@ -11,66 +11,62 @@ import edu.wpi.first.wpilibj.command.Command; * */ public class DriveFor extends Command { - private double seconds; - private Timer timer; - private Direction direction; + private double seconds; + private Timer timer; + private Direction direction; - public DriveFor(double seconds, Direction direction) { - this.seconds = seconds; - this.direction = direction; + public DriveFor(double seconds, Direction direction) { + this.seconds = seconds; + this.direction = direction; - } + } - @Override - protected void initialize() { - timer = new Timer(); - timer.reset(); - timer.start(); - } + @Override + protected void initialize() { + timer = new Timer(); + timer.reset(); + timer.start(); + } - @Override - protected void execute() { - System.out.println(timer.get()); - if (direction == Direction.FORWARD) { - if (timer.get() < seconds * 0.2) { // for the first 20% of time, run - // the robot at -.5 speed - Robot.driveTrain.arcadeDrive(-0.3, 0); - } else if (timer.get() >= seconds * 0.2 - && timer.get() <= seconds * 0.8) { // for the +20% - 75% - // time, move the robot - // at -.3 speed. - Robot.driveTrain.arcadeDrive(-0.5, 0); - } else if (timer.get() < seconds) { - Robot.driveTrain.arcadeDrive(-0.25, 0); - } else { - Robot.driveTrain.arcadeDrive(0, 0); - } - } else if (direction == Direction.BACKWARD) { - if (timer.get() < seconds * 0.2) { - Robot.driveTrain.arcadeDrive(0.3, 0); - } else if (timer.get() >= seconds * 0.2 - && timer.get() <= seconds * 0.8) { - Robot.driveTrain.arcadeDrive(0.5, 0); - } else if (timer.get() < seconds) { - Robot.driveTrain.arcadeDrive(0.25, 0); - } else { - Robot.driveTrain.arcadeDrive(0, 0); - } - } + @Override + protected void execute() { + System.out.println(timer.get()); + if (direction == Direction.FORWARD) { + if (timer.get() < seconds * 0.2) { // for the first 20% of time, run + // the robot at -.5 speed + Robot.driveTrain.arcadeDrive(-0.3, 0); + } else if (timer.get() >= seconds * 0.2 && timer.get() <= seconds * 0.8) { + Robot.driveTrain.arcadeDrive(-0.5, 0); + } else if (timer.get() < seconds) { + Robot.driveTrain.arcadeDrive(-0.25, 0); + } else { + Robot.driveTrain.arcadeDrive(0, 0); + } + } else if (direction == Direction.BACKWARD) { + if (timer.get() < seconds * 0.2) { + Robot.driveTrain.arcadeDrive(0.3, 0); + } else if (timer.get() >= seconds * 0.2 && timer.get() <= seconds * 0.8) { + Robot.driveTrain.arcadeDrive(0.5, 0); + } else if (timer.get() < seconds) { + Robot.driveTrain.arcadeDrive(0.25, 0); + } else { + Robot.driveTrain.arcadeDrive(0, 0); + } } + } - @Override - protected boolean isFinished() { - return timer.get() > seconds; - } + @Override + protected boolean isFinished() { + return timer.get() > seconds; + } - @Override - protected void end() { - Robot.driveTrain.arcadeDrive(0, 0); - } + @Override + protected void end() { + Robot.driveTrain.arcadeDrive(0, 0); + } - @Override - protected void interrupted() { - end(); - } + @Override + protected void interrupted() { + end(); + } }