CommunicationController

General description

The “CommunicationController” component can be used to send data from a simulation to another using ZMQ library. To use this component you need to enable “SOFTROBOTS_COMMUNICATIONCONTROLLER” option in cmake, and install the ZMQ library (“SoftRobots/component/controller/README.txt”).


How to use the component

To learn how to create a SOFA scene, please refer to the tutorial provided by the SOFA Modeler or this documentation.

Here is an example of how you can use the CommunicationController. In this example we want to solve the motion of our robot in an inverse simulation, and check the “controllability” of this robot by running in parallele the corresponding forward simulation (i.e the input of the forward simulation will be the results of the inverse problem). You should put in each simulation:

1- Sender

robot.createObject('CommunicationController', listening='1', job="sender", port="5558", nbDataField="4",
 data1="@cavity/pressure.volumeGrowth",
 data2="@cables/cable1.displacement",
 data3="@cables/cable2.displacement",
 data4="@cables/cable3.displacement")

2- Receiver

 robot.createObject('CommunicationController', name="sub", listening='1', job="receiver", port="5558", nbDataField="4")
 
...

cavity.createObject('SurfacePressureConstraint'...
value="@../sub.data1")

...

cables.createObject('CableConstraint', ...
value = "@../sub.data2")

cables.createObject('CableConstraint', ...
value = "@../sub.data3")

cables.createObject('CableConstraint', ...
value = "@../sub.data4")

Please see the example provided in the “example/component/controller” directory of the plugin.
In each simulation, you should specify either the component should send or receive data. In both simulation, you should use the same port and pattern for the communication. You can choose a pattern between, request/reply and publish/subscribe. The type of the datas is specified using templates. So if you want to send two different types of data, you’ll have to use two components. Each option is described in the following section.

Data field

Input data

job : Select choice between sender and receiver.

pattern : Pattern used for communication.
1- publish/subscribe: Messages sent are distributed in a fan out fashion to all connected peers. Never blocks.
2- request/reply: Message sent are waiting for reply. Allows only an alternating sequence of send\reply calls.
Default is publish/subscribe.

port : Port for communication.

ip : If receiver, you can specify the IP adress of the sender. If not, it will setup a local communication.

nbDataField : Number of data to send/receive. Default is 1.

data1, data2 , … : The data you want to send/receive. The data fields are created with respect to nbDataField you provide.
Ex: If nbDataField = 5, you will have access to data1, data2, data3, data4 and data5
Default nbDataField = 1, you will only have access to data1 (i.e there will be no data2, …)

WARNING: the pattern should be the same for both sender and receiver to be effective.

Comments are closed.