Hey,
During the season we noticed two things: The first, it is not possible to cancel a Command inside a CommandGroup. The second, we wanted sometimes to delay a Command inside a CommandGroup. For example, inside the Auto Scale code, we wanted the Lift to go up while driving, so we used addParrallel(). However, that made the Lift go up instantly when the robot started driving, and we wanted it to go up only a few seconds before the robot reached the scale.
Is there a nice way you found to do these two things? Thanks! :yikes:
For delaying a parallel command, you can use a CommandGroup. Construct a CommandGroup with two serial tasks: a delay and the Command you’re looking to run. Then, in another CommandGroup, add it as a parallel task.
More specifically:
public class ExecuteAfterWait extends CommandGroup {
public ExecuteAfterWait(double time, Command command) {
addSequential(new WaitCommand(time));
addSequential(command);
}
}
Usage:
addParallel(new ExecuteAfterWait(3.0, new ElevatorSetHeight(...)));
addSequential(new DriveDistance(...));