add javadocs for DriveStraightForTime and include timer code
[3501/2017steamworks] / src / org / usfirst / frc / team3501 / robot / commands / driving / DriveStraightForTime.java
CommitLineData
f8be4551
ME
1package org.usfirst.frc.team3501.robot.commands.driving;
2
3import org.usfirst.frc.team3501.robot.Robot;
4
5import edu.wpi.first.wpilibj.Timer;
6import edu.wpi.first.wpilibj.command.Command;
7
8/**
9 * This command drives the robot for a specified time while adjusting the right
10 * and left motor values so that the robot will drive straight
11 *
12 * parameters:
13 * time in seconds
14 * motorVal
15 *
16 * @author Meryem
17 * @author Niyati
18 *
19 */
20public class DriveStraightForTime extends Command {
21 Timer timer;
22 double time, motorVal;
23
24 public DriveStraightForTime(double time, double motorVal) {
25 requires(Robot.getDriveTrain());
26
27 timer = new Timer();
28 this.time = time;
29
30 this.motorVal = motorVal;
31
32 }
33
34 @Override
35 protected void initialize() {
36 timer.start();
37 }
38
39 @Override
40 protected void execute() {
41 }
42
43 @Override
44 protected boolean isFinished() {
45 return timer.get() >= time;
46 }
47
48 @Override
49 protected void end() {
50 Robot.getDriveTrain().stop();
51 }
52
53 @Override
54 protected void interrupted() {
55 end();
56 }
57}