fix conflicts
[3501/2015-FRC-Spark] / src / org / usfirst / frc3501 / RiceCatRobot / commands / TurnFor.java
CommitLineData
f11ce98e
KZ
1package org.usfirst.frc3501.RiceCatRobot.commands;
2
4b8a525f
KZ
3import org.usfirst.frc3501.RiceCatRobot.robot.Robot;
4import org.usfirst.frc3501.RiceCatRobot.robot.RobotMap.Direction;
f11ce98e
KZ
5
6import edu.wpi.first.wpilibj.Timer;
7import edu.wpi.first.wpilibj.command.Command;
8
9public class TurnFor extends Command {
e3bfff96
KZ
10 private double seconds;
11 private Timer timer;
12 private Direction direction;
13
14 public TurnFor(double seconds, Direction direction) {
15 this.seconds = seconds;
16 this.direction = direction;
17 }
18
19 @Override
20 protected void initialize() {
21 timer = new Timer();
22 timer.start();
23 }
24
25 @Override
26 protected void execute() {
27 if (direction == Direction.LEFT) {
28 Robot.driveTrain.arcadeDrive(0, -0.5);
29 } else if (direction == Direction.RIGHT) {
30 Robot.driveTrain.arcadeDrive(0, 0.5);
31 } else {
32 Robot.driveTrain.arcadeDrive(0, 0);
f11ce98e 33 }
e3bfff96
KZ
34 }
35
36 @Override
37 protected boolean isFinished() {
38 System.out.println(timer.get());
39 System.out.println(seconds);
40 if (timer.get() > seconds) {
41 Robot.driveTrain.arcadeDrive(0, 0);
f11ce98e 42 }
e3bfff96
KZ
43 return timer.get() > seconds;
44 }
f11ce98e 45
e3bfff96
KZ
46 @Override
47 protected void end() {
48 }
f11ce98e 49
e3bfff96
KZ
50 @Override
51 protected void interrupted() {
52 end();
53 }
f11ce98e 54}