-
Notifications
You must be signed in to change notification settings - Fork 628
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
[wpilibNewCommands] Add get subsystem list function from CommandScheduler #7835
base: main
Are you sure you want to change the base?
Conversation
This PR modifies commands. Please open a corresponding PR in Python Commands and include a link to this PR. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the intent to do a copy or return an object that is a readonly view? (Does the below work?)
Set<Subsystem> subsystems = CommandScheduler.getInstance().getAllRegisteredSubsystems();
Subsystem mySubsystem = new Subsystem() {};
CommandScheduler.getInstance.registerSubsystem(mySubsystem);
assertTrue(subsystems.contains(mySubsystem));
As it is right now, Java is a readonly view (the code snippet above will pass) while C++ is a copy (the C++ version of the above will not pass).
See #6475 for discussion of this feature and #6526 for the troubles encountered a year ago in getting the readonly view to work in C++.
robotpycommands2 pr: robotpy/robotpy-commands-v2#86 |
Ideally it will be a readonly view in c++, as that makes the most sense but might have to make both copies if it turns out that we can't get the readonly view to compile in cpp |
In java, the subsystems are returned as an immutable set and in c++ they are returned as a const vector. No tests for these as there isn't testing framework to create mock subsystems in wpilibNewCommands tests, at least not that I'm aware of.