package org.usfirst.frc.team3501.robot.commands.driving;
+import org.usfirst.frc.team3501.robot.Constants;
import org.usfirst.frc.team3501.robot.Constants.Direction;
import org.usfirst.frc.team3501.robot.Robot;
* post-condition: robot has turned in the specified direction for the specified
* time
*
+ * TODO: test for speed/ time constants for specific angles (ex. 30 degrees, 60
+ * degrees, 90 degrees)
+ *
* @author Meryem, Avi, and Sarvesh
*
*/
public class TurnForTime extends Command {
- private final double 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, Constants.Auton.DEFAULT_SPEED);
}
@Override
timer.start();
if (direction == Direction.RIGHT) {
- Robot.driveTrain.setMotorSpeeds(SPEED, -SPEED);
+ // Robot.driveTrain.drive(speed, -speed);
+ Robot.driveTrain.arcadeDrive(0, speed);
} else if (direction == Direction.LEFT) {
- Robot.driveTrain.setMotorSpeeds(-SPEED, SPEED);
+ // Robot.driveTrain.drive(-speed, speed);
+ Robot.driveTrain.arcadeDrive(0, speed);
}
}
@Override
protected boolean isFinished() {
- if (timer.get() >= seconds)
- return true;
- return false;
+ return (timer.get() >= seconds);
}
@Override
protected void end() {
+ Robot.driveTrain.drive(0, 0);
}
@Override
protected void interrupted() {
+ end();
}
}