1 package org
.usfirst
.frc
.team3501
.robot
.commands
.driving
;
3 import org
.usfirst
.frc
.team3501
.robot
.Constants
.Direction
;
4 import org
.usfirst
.frc
.team3501
.robot
.Robot
;
6 import edu
.wpi
.first
.wpilibj
.Timer
;
7 import edu
.wpi
.first
.wpilibj
.command
.Command
;
10 * This command turns the robot in a specified direction for a specified
11 * duration in seconds.
13 * pre-condition: robot is on a flat surface
15 * post-condition: robot has turned in the specified direction for the specified
18 * @author Meryem, Avi, and Sarvesh
22 public class TurnForTime
extends Command
{
23 private static final double DEFAULT_SPEED
= 0.5;
24 private Direction direction
;
25 private double seconds
;
29 public TurnForTime(double seconds
, Direction direction
, double speed
) {
30 this.seconds
= seconds
;
31 this.direction
= direction
;
35 public TurnForTime(double seconds
, Direction direction
) {
36 this(seconds
, direction
, DEFAULT_SPEED
);
40 protected void initialize() {
44 if (direction
== Direction
.RIGHT
) {
45 Robot
.driveTrain
.setMotorSpeeds(speed
, -speed
);
46 } else if (direction
== Direction
.LEFT
) {
47 Robot
.driveTrain
.setMotorSpeeds(-speed
, speed
);
52 protected void execute() {
57 protected boolean isFinished() {
58 if (timer
.get() >= seconds
)
64 protected void end() {
65 Robot
.driveTrain
.setMotorSpeeds(0, 0);
69 protected void interrupted() {