I have a LeafSystem (using pydrake) with a couple of inputs and an output which is calculated from the inputs. The CalcOutput
callback function blocks execution of the program until the output is set. In some cases, I prefer to not set the output even if there is an input (eg.out of the limit values).
Is there a way to continue execution, without setting the output?
Drake System's framework uses a "pull" architecture. All of the system evaluations happen in a single thread, and CalcOutput
is only called when a downstream method is evaluated which requests an input (e.g. in a downstream CalcOutput
or CalcTimeDerivatives
). So you need to return some value.
I guess that instead of returning some null
value, you probably want to just have the output port continue to have the value it output last time? In that case, the solution is to store the output in a state variable (which means moving the work in CalcOutput
into a state update), and then having your output just write the state variable out to the port.