Liqian
Liqian

Reputation: 41

Strategies for Non-Blocking Control in Drake

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:

  1. In system A, somehow make the object detection not blocking. If the object detection is not done, system A will just provide the last calculated goal.
  2. Add another system C, so the whole system becomes A->B->C->Robot. System C would forward the control input to the robot if the calculation completes within 1 ms. If it takes longer, C would generate an alternative input to keep the robot stationary. The advantage might be it can guarantee real-time control no matter what systems are connected before it.

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

Answers (1)

Russ Tedrake
Russ Tedrake

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

Related Questions