368d10459f2289f94a406ff3ecc1ece79653592b
1 package org
.usfirst
.frc
.team3501
.robot
.commands
.driving
;
3 import org
.usfirst
.frc
.team3501
.robot
.Constants
;
4 import org
.usfirst
.frc
.team3501
.robot
.Constants
.Direction
;
5 import org
.usfirst
.frc
.team3501
.robot
.Robot
;
7 import edu
.wpi
.first
.wpilibj
.Timer
;
8 import edu
.wpi
.first
.wpilibj
.command
.Command
;
11 * This command turns the robot in a specified direction for a specified
12 * duration in seconds.
14 * pre-condition: robot is on a flat surface
16 * post-condition: robot has turned in the specified direction for the specified
19 * TODO: test for speed/ time constants for specific angles (ex. 30 degrees, 60
20 * degrees, 90 degrees)
22 * @author Meryem, Avi, and Sarvesh
26 public class TurnForTime
extends Command
{
27 private Direction direction
;
28 private double seconds
;
32 public TurnForTime(double seconds
, Direction direction
, double speed
) {
33 this.seconds
= seconds
;
34 this.direction
= direction
;
38 public TurnForTime(double seconds
, Direction direction
) {
39 this(seconds
, direction
, Constants
.Auton
.DEFAULT_SPEED
);
43 protected void initialize() {
47 if (direction
== Direction
.RIGHT
) {
48 Robot
.driveTrain
.drive(speed
, -speed
);
49 } else if (direction
== Direction
.LEFT
) {
50 Robot
.driveTrain
.drive(-speed
, speed
);
55 protected void execute() {
60 protected boolean isFinished() {
61 return (timer
.get() >= seconds
);
65 protected void end() {
66 Robot
.driveTrain
.drive(0, 0);
70 protected void interrupted() {