/***
* This command turns the robot in a specified direction for a specified
- * duration.
+ * duration in seconds.
*
* pre-condition: robot is on a flat surface
*
*/
public class TurnForTime extends Command {
- private final double SPEED = 0.5;
+ private static final double DEFAULT_SPEED = 0.5;
private Direction direction;
private double seconds;
private Timer timer;
+ private double speed;
- public TurnForTime(double seconds, Direction direction) {
+ public TurnForTime(double seconds, Direction direction, double speed) {
this.seconds = seconds;
this.direction = direction;
+ this.speed = speed;
+ }
+
+ public TurnForTime(double seconds, Direction direction) {
+ this(seconds, direction, DEFAULT_SPEED);
}
@Override
protected void initialize() {
timer = new Timer();
timer.start();
- }
- @Override
- protected void execute() {
if (direction == Direction.RIGHT) {
- Robot.driveTrain.setMotorSpeeds(SPEED, -SPEED);
+ Robot.driveTrain.setMotorSpeeds(speed, -speed);
} else if (direction == Direction.LEFT) {
- Robot.driveTrain.setMotorSpeeds(-SPEED, SPEED);
+ Robot.driveTrain.setMotorSpeeds(-speed, speed);
}
}
+ @Override
+ protected void execute() {
+
+ }
+
@Override
protected boolean isFinished() {
if (timer.get() >= seconds)
@Override
protected void end() {
+ Robot.driveTrain.setMotorSpeeds(0, 0);
}
@Override