clean up DriveForTime
[3501/2015-FRC-Spark] / src / org / usfirst / frc3501 / RiceCatRobot / commands / DriveForTimesSequence.java
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 public DriveForTimesSequence(double[][] timings) {
26 for (int i = 0; i < timings.length; i++) {
27 double time = timings[i][0];
28 double speed = timings[i][1];
29
30 addSequential(new DriveForTime(time, speed));
31 }
32 }
33 }