changed set to return
[3501/2017steamworks] / src / org / usfirst / frc / team3501 / robot / commands / driving / TimeDrive.java
1 package org.usfirst.frc.team3501.robot.commands.driving;
2
3 import org.usfirst.frc.team3501.robot.Robot;
4
5 import edu.wpi.first.wpilibj.Timer;
6 import edu.wpi.first.wpilibj.command.Command;
7
8 /***
9 * This commands make the robot drive for a specified time with the motors set
10 * at a specified value between 1 and -1
11 *
12 * parameters: time: how long the robot should drive for - in seconds motorVal:
13 * the motor input to set the motors to
14 *
15 *
16 */
17 public class TimeDrive extends Command {
18 Timer timer;
19 double motorVal, motorValTwo, time;
20
21 public TimeDrive(final double time, final double motorVal) {
22 requires(Robot.getDriveTrain());
23
24 timer = new Timer();
25 this.time = time;
26 this.motorVal = motorVal;
27 }
28
29 @Override
30 protected void initialize() {
31 timer.start();
32 }
33
34 @Override
35 protected void execute() {
36 double[] motorValues;
37 motorValues = Robot.getDriveTrain().correctStraightness();
38 motorVal = motorValues[0];
39 motorValTwo = motorValues[1];
40 Robot.getDriveTrain().setMotorValues(motorVal, motorValTwo);
41
42 }
43
44 @Override
45 protected boolean isFinished() {
46 return timer.get() >= time;
47 }
48
49 @Override
50 protected void end() {
51 Robot.getDriveTrain().stop();
52 }
53
54 @Override
55 protected void interrupted() {
56 end();
57 }
58 }