Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Trigger factories for common robot state events #5151

Closed
Oblarg opened this issue Mar 1, 2023 · 4 comments · Fixed by #5902
Closed

Add Trigger factories for common robot state events #5151

Oblarg opened this issue Mar 1, 2023 · 4 comments · Fixed by #5902
Labels
component: command-based WPILib Command Based Library type: feature Brand new functionality, features, pages, workflows, endpoints, etc.

Comments

@Oblarg
Copy link
Contributor

Oblarg commented Mar 1, 2023

These would sugar event bindings for transitions between the various robot control modes, etc:

// naming and location TBD
static Trigger disabled() {
  return new Trigger(DriverStation::isDisabled);
}

The static factory methods doing this could live on Trigger, or on the classes whose state they're relevant to.

@a-viv-a
Copy link

a-viv-a commented Mar 3, 2023

This would certainly be nice, it can already be achieved by modifying the Robot.java file and calling new methods in your RobotContainer (is there a better way at present?). I figured there was some reason these events weren't exposed.

@Starlight220
Copy link
Member

it can already be achieved by modifying the Robot.java file and calling new methods in your RobotContainer (is there a better way at present?)

It could be achieved like the implementation in the original post: new Trigger(DriverStation::isAutonomous) etc.

If you're calling Robot from your RobotContainer, that's a circular dependency code smell.

@Oblarg
Copy link
Contributor Author

Oblarg commented Mar 3, 2023

@isaec these aren't exposed mostly because the current command-based API is still evolving and no one had thought to add them yet.

@Oblarg
Copy link
Contributor Author

Oblarg commented Mar 3, 2023

@isaec along these lines, if you can think of other convenience factories that'd be useful, please open github issues for them.

@calcmogul calcmogul added type: feature Brand new functionality, features, pages, workflows, endpoints, etc. component: command-based WPILib Command Based Library labels Aug 2, 2023
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 type: feature Brand new functionality, features, pages, workflows, endpoints, etc.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants