Imagine the bin picking scenario:
I would like to implement the grasp detection procedure, which will be invoked once from time to time. This meant that the procedure will just stay idle, doing nothing, while waiting for the call. In ROS, I would probably use ROS-Service to achieve this. I would like to ask for a suggestion of best practice to do this in Drake framework.
I have also considered a few designs, but they didn't answer my requirement yet.
P.S. This might not be directly related to the topic. But to achieve the deterministic behaviors for testing in above setup, am I correct that
Ok. Thank you for clarifying. The timing semantics are simplest and most crisp in a single process. I prefer to get those right, first, and then introduce LCM/ROS only as a means to split up the computation across multiple processes (for performance, or to use a different compilation unit for a device driver, etc).
You can write your controller to be continuous time or discrete time (as seen in the tutorials). In the vast amount of cases, these will be the right semantics. I believe you are imagining a case where you have an occasional event (e.g. "a new object was detected" or "I need to replan") which would often appear as an RPC service call in ROS. We do have provisions for these in Drake (see e.g. "declare forced events" in LeafSystem), but it's often much cleaner to simply implement these as, e.g. a simple discrete time system that checks its import port and only does work if the input port value has changed in a way to trigger that activity. The overhead of this approach is very small, and the advantage of the easier semantics is that you can use more tools for log analysis, planning, control, verification, etc.
I hope that addresses the question. If you have a specific case that doesn't fit, let us know.