I have a LeafSystem (controller) with two output ports, each of which depend on the solution to the same MathematicalProgram. My initial idea was to solve the program and store the solution as a discrete state which the output port callbacks can access and copy appropriately.
My interpretation of the documentation (https://drake.mit.edu/doxygen_cxx/group__discrete__systems.html) and what I see when implementing this, however, is that the output callbacks use the discrete state before the PerStepDiscreteUpdateEvent.
Now for my questions -
- Is this behavior that I've described above consistent with how the Simulator handles update events or am I missing something there?
- Is there a way to update the discrete state before the output calculation and have the updated state be used in the output?
- Is there a different design that would be more appropriate here?