-
Notifications
You must be signed in to change notification settings - Fork 613
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
Allow unsetting a subsystem's default command #4621
Conversation
I don't think this is how we should handle this. Currently the semantics of changing a Subsystem's default command aren't clearly defined, and shouldn't be relied upon. Additionally, I don't think calling |
a) Would you suggest adding a new b) That seems like that would require a whole rework of the default command and subsystem registration system... |
A Subsystems should be mostly RAII; re-registering them (especially without calling As mentioned, default commands in their current form fall under configuration, and shouldn't be set more than once. For a while I've been thinking of demystifying default commands and refactoring them into Trigger bindings, basically adding syntax sugar around the following: new Trigger(subsystem.requiring() == null, loop).onTrue(command) This should help a bit with clarifying semantics and when default commands can be changed. |
I think that might help solve some of the problems and resolve some of the semantics. Is that something we can target for this season? If not, I think we should check if the subsystem is already registered, and either noop or throw an exception. I'd vote for no-op, as the documentation does not state that |
I can try to write up a PR this week. |
Needs a unit test and C++. |
Changes the behavior so calling
setDefaultCommand(subsystem, null)
unsets the default command ofsubsystem
. I realize that callingregister
on thesubsystem
does the same thing, but this behavior is more explicit and intuitive.I don't know how to do the C++ translation...