+++ /dev/null
-package org.usfirst.frc3501.RiceCatRobot.commands;
-
-import org.usfirst.frc3501.RiceCatRobot.Robot;
-import org.usfirst.frc3501.RiceCatRobot.RobotMap.Direction;
-import org.usfirst.frc3501.RiceCatRobot.subsystems.DriveTrain;
-
-import edu.wpi.first.wpilibj.Timer;
-import edu.wpi.first.wpilibj.command.Command;
-
-/**
- * This command takes a time in seconds which is how long it should run
- *
- */
-public class DriveFor extends Command {
- private double seconds;
- private double speed;
- private Timer timer;
- private Direction direction;
-
- public DriveFor(double seconds, double speed, Direction direction) {
- // limit speed to the range [0, MOTOR_MAX_VAL]
- this.speed = Math.max(speed, -speed);
- this.speed = Math.min(speed, DriveTrain.MOTOR_MAX_VAL);
-
- this.seconds = seconds;
- this.direction = direction;
- }
-
- @Override
- protected void initialize() {
- timer = new Timer();
- timer.reset();
- timer.start();
- }
-
- @Override
- protected void execute() {
- if (direction == Direction.FORWARD) {
- Robot.driveTrain.setMotorSpeeds(-speed, -speed);
- } else if (direction == Direction.BACKWARD) {
- Robot.driveTrain.setMotorSpeeds(speed, speed);
- }
- }
-
- @Override
- protected boolean isFinished() {
- return timer.get() > seconds;
- }
-
- @Override
- protected void end() {
- Robot.driveTrain.setMotorSpeeds(0, 0);
- }
-
- @Override
- protected void interrupted() {
- end();
- }
-}
\ No newline at end of file