Reputation: 41
I want to use Drake to control a robot arm to reach a goal with its end effector. I want to control the robot at 1kHz. Say I will control the robot with cartesian stiffness control. This part is a LeafSystem
B which can easily reach 1kHz. There is another LeafSystem
A that will use a deep network to detect the goal and provide it to the cartesian stiffness controller. Say this object detection process will consume 1-10s (can vary so not periodical). It seems Eval
is a blocking method so if I implement the object detection process in A's output port, the whole simulation will be blocked to wait for that calculation. However, I don't want to block the simulation. I want the control signal to be sent to the robot at 1kHz. If the object detection has not been done, the robot should stay still and wait.
I came up with two methods:
I'm wondering what is the right way to do this. I want to avoid blocking because I want to use Drake to control a real robot at 1kHz. Any insights or suggestions would be greatly appreciated.
Upvotes: 0
Views: 63
Reputation: 5533
In practice, this is often realized by having e.g. the perception system running in a different process. The LCM Subscriber (or ROS Subscriber) will change the value of their output ports when new message are received, but will not block the main simulation thread waiting for messages.
If your goal is to do this in a single process, then that can be realized by the relatively complicated mechanism used by the implementation of LcmSubscriberSystem, or by polling for the new detections in a LeafSystem with a periodic update.
Upvotes: 1