Commit | Line | Data |
---|---|---|
0781814f ME |
1 | package org.usfirst.frc.team3501.robot.commands;\r |
2 | \r | |
3 | import org.usfirst.frc.team3501.robot.Robot;\r | |
4 | \r | |
5 | import edu.wpi.first.wpilibj.Timer;\r | |
6 | import edu.wpi.first.wpilibj.command.Command;\r | |
7 | \r | |
8 | /**\r | |
9 | * This command\r | |
10 | */\r | |
11 | public class DriveForTime extends Command {\r | |
12 | \r | |
13 | private final static double DEFAULT_SPEED = 0.5;\r | |
14 | private double speed;\r | |
15 | private double seconds;\r | |
16 | \r | |
17 | private Timer timer;\r | |
18 | \r | |
19 | public DriveForTime(double seconds, double speed) {\r | |
20 | this.seconds = seconds;\r | |
21 | this.speed = speed;\r | |
22 | }\r | |
23 | \r | |
24 | public DriveForTime(double seconds) {\r | |
25 | this(seconds, DEFAULT_SPEED);\r | |
26 | }\r | |
27 | \r | |
28 | @Override\r | |
29 | protected void initialize() {\r | |
30 | timer = new Timer();\r | |
31 | timer.start();\r | |
32 | \r | |
33 | Robot.driveTrain.setMotorSpeeds(speed, speed);\r | |
34 | }\r | |
35 | \r | |
36 | @Override\r | |
37 | protected void execute() {\r | |
38 | }\r | |
39 | \r | |
40 | @Override\r | |
41 | protected boolean isFinished() {\r | |
42 | if (timer.get() >= seconds)\r | |
43 | return true;\r | |
44 | return false;\r | |
45 | }\r | |
46 | \r | |
47 | @Override\r | |
48 | protected void end() {\r | |
49 | Robot.driveTrain.setMotorSpeeds(0, 0);\r | |
50 | }\r | |
51 | \r | |
52 | @Override\r | |
53 | protected void interrupted() {\r | |
54 | }\r | |
55 | }\r |