-
Notifications
You must be signed in to change notification settings - Fork 615
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 an event in CommandScheduler before each command is executed #7125
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. |
Both of the use cases mentioned are already possible; I'm not sure what this improves |
Could you provide me some more detail about how to report the currently-executing Command without this change? I wasn't able to find a way to do that. I would like to be able to add an assertion like this in my Subsystem: |
By currently-executing command do you mean the command currently being iterated on by the scheduler, and not simply currently scheduled? Ensuring requirements is more simply done via using subsystem factory methods and access control etc. Command timings are already recorded by the scheduler tracer/watchdog; maybe there's room for improvement with exposing that data. |
For timing/profiling commands, see #7099 |
Yes
With the Trigger/FunctionalCommand lambdas being in Defensive Programming best practice is to have the receiver, not the caller, validate preconditions. |
That's the idea behind the paradigm of subsystems' public API only consisting of command factories and reading accessors/Triggers. |
The new
onBeforeExecute
event parallels the existingonCommandExecute
, butonBeforeExecute
is run immediately before theexecute()
of each Command, whereasonCommandExecute
is run immediately after. This allows for such uses as profiling the runtime of each Command, or reporting which Command is currently running.