Using Java and the new command framework, does anyone have a creative idea for how to repeatedly run a commandgroup while a button is held? We have a sequence of commands we’d like to run, and when they are done running we’d like to run them again, as long as the button is held.
Here’s the command group and button binding. This runs it once:
var pixyHeldCommand = new PixyAssistCommand(driveTrainSubsystem, pixyVision)
.andThen(new ParallelCommandGroup(
new RunCommand(intakeSubsystem::intake, intakeSubsystem),
new RunCommand(() -> driveTrainSubsystem.arcadeDrive(.2, 0, false), driveTrainSubsystem).withTimeout(2)));
new JoystickButton(driverController, XboxController.Button.kX.value)
.whenHeld(pixyHeldCommand)
The .perpetually()
decorator was the first thought, but that won’t loop around and run the sequence over again.