Skip to content

Conversation

Braykoff
Copy link
Contributor

@Braykoff Braykoff commented Jul 16, 2025

Resolves #7992

TriggerGroups allow users to combine multiple Triggers to run a command when a specific combination of Triggers become true. For example:

TriggerGroup group = new TriggerGroup(Map.of("a", controller.a(), "b", controller.b(), "c", controller.c()));

group.only("a", "b").whileTrue(...); // Runs when a and b are true, and c is false
group.any("a", "b").whileTrue(...); // Runs when either a or b are true
group.allOf("a", "b").whileTrue(...); // Runs when a and b are true
group.all().whileTrue(...); // Runs when a, b, and c are true
group.none().whileTrue(); // Runs when a, b, and c are false

Also has a cpp implementation and unit tests.

TriggerGroups can also be created by chaining the .add method:

TriggerGroup group = new TriggerGroup()
  .add("a", controller.a())
  .add("b", controller.b());

TriggerGroups are immutable.

@Braykoff Braykoff requested a review from a team as a code owner July 16, 2025 20:57
Copy link
Contributor

This PR modifies commands. Please open a corresponding PR in Python Commands and include a link to this PR.

@github-actions github-actions bot added the component: command-based WPILib Command Based Library label Jul 16, 2025
@Daniel1464
Copy link
Contributor

Make TriggerGroup accept generic keys, so you can use enums(which are much more typesafe) over raw, case-sensitive strings

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: command-based WPILib Command Based Library
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Joystick Button Groups
2 participants