Commit | Line | Data |
---|---|---|
bb007582 D |
1 | package org.usfirst.frc3501.RiceCatRobot.commands; |
2 | ||
3 | import org.usfirst.frc3501.RiceCatRobot.Robot; | |
4 | import org.usfirst.frc3501.RiceCatRobot.RobotMap.Direction; | |
5 | ||
6 | import edu.wpi.first.wpilibj.Timer; | |
7 | import edu.wpi.first.wpilibj.command.Command; | |
8 | import edu.wpi.first.wpilibj.command.CommandGroup; | |
9 | ||
10 | /** | |
11 | * Command to drive an arbitrary sequences of speeds and times. You can use this | |
12 | * to approximate acceleration by driving 0.5 sec at speed 0.1, 0.5 sec at speed | |
13 | * 0.2, and so on. | |
14 | */ | |
15 | public class DriveForTimesSequence extends CommandGroup { | |
16 | ||
17 | /*** | |
18 | * | |
19 | * @param timings | |
20 | * an array of speeds and times. Each row represents a time and speed | |
21 | * to drive at. Column 0 represents the time in seconds to drive for | |
22 | * and column 1 represents the speed to drive at. E.g. { {1, 0.5}, | |
23 | * {2, 0.75} } will drive at 0.5 for 1 second and 0.75 for 2 seconds | |
24 | * | |
25 | * @param direction | |
26 | * this is Direction.Forward or Direction.Backward all speeds in the | |
27 | * timings array will apply in this direction. | |
28 | */ | |
29 | public DriveForTimesSequence(double[][] timings, Direction direction) { | |
30 | for (int i = 0; i < timings.length; i++) { | |
31 | double time = timings[i][0]; | |
32 | double speed = timings[i][1]; | |
33 | ||
34 | addSequential(new DriveFor(time, speed, direction)); | |
35 | } | |
36 | } | |
37 | } |