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
String tags for commands for easier command identification #6510
Comments
I feel like the use cases can be implemented using the name field, without needing to tack on another metadata field |
Also this likely wouldn't fix the issue of compositions without the same issue being fixed for normal names |
Yes, this is true, however the issue comes when commands are composed. When commands are composed they lose their name (and thus the data stored in the name). Because tags would be inherited by the composing command, the data isn't lost.
I not sure how you would fix the issue of compositions with normal names. Lets take the example of sequencing 3 commands:
What would the name of the composed command be? Currently it's just "SequencedCommandGroup", which doesn't provide any unique data. If the suggested name is "[command1.getName()], [command2.getName()], [command3.getName()]", this is far from readable (the main purpose of command names). |
Why can’t you just decorate using .withName()? Eg Commands.sequence(a,b,c).withName(“quick auto”)? |
You can, but it still has lost the data from the commands inside. |
Here's a real case where these tags would be useful. In our (Team 686) code, we have a shooter subsystem (only controls the flywheels) and a kicker subsystem (rollers that push the note into our flywheels). Lets say that we want to implement an auto-shoot trigger that will schedule
In our shooter commands, we would have only the commands that are attempting to fire at the speaker have the auto-shoot tag. |
I imagine other will say that basing triggers not off the state of the system but off the state of the command schedule is an anti-pattern. Why not have
and |
Is the command not the state of the system? From my point of view the command scheduler is a beefed-up state machine without the convenience of easy state checking.
How would I have realized a potential issue with tags where a sequenced command will have the tags of commands that might not be currently running, which might cause undesired behavior. |
Is your feature request related to a problem? Please describe.
When using
SubsystemBase.getCurrentCommand
there's no way of identifying the command without using the type or name of the command. This gets even worse if the command is part of a composition (like an autonomous command).Describe the solution you'd like
Commands would have an internal list of tags and would have functions like
Command.addTags(String... tags)
Command.withTags(String... tags)
Command.hasTags(String... tags)
Compositions would simply inherit all tags of child commands.
In practice these tags would be static Strings inside of either a SubsystemBase or a constants class, as to reduce the amount of String literals that have to match each other.
Example Code:
Describe alternatives you've considered
Using the name of a command to identify the command is possible (and is something our team has done with copious amounts of proxies) but is not desirable as the command name is meant for other purposes.
Additional context
This sort of functionality would go well with #6511
The text was updated successfully, but these errors were encountered: