Closed nunoguedelha closed 2 years ago
Not sure that we need to use it, but we may be interested in http://www.yarp.it/latest/persistent_connections.html .
we shall try using the approaches suggested by @traversaro (http://www.yarp.it/latest/persistent_connections.html), creating persistent connections programmatically:
yarp.Network.connect
with the option "persistent" set as follows:
#include <yarp/os/Network.h>
#include <yarp/os/ContactStyle.h>
...
yarp::os::Network yarp;
yarp::os::ContactStyle style;
style.persistent = true;
Network::connect("/foo","/bar",style);
#include <yarp/os/Network.h>
...
yarp::os::Network yarp;
yarp.connect("/camera1","topic://vision");
#include <yarp/os/Network.h>
...
yarp::os::Network yarp;
yarp.connect("topic://vision","/viewer");
The code snippets above are in C++. We don't know if the style
option is supported by the yarp::os::Network
class bindings, nor if the bindings to the class yarp::os::ContactStyle
exist at all...
yarp connect --persist OUTPUT_PORT INPUT_PORT
yarp connect --persist-from OUTPUT_PORT INPUT_PORT
yarp connect --persist-to OUTPUT_PORT INPUT_PORT
yarp::os::ContactStyle
are not implemented.$ yarp connect /write topic://aTopic
[INFO] |yarp.os.Network| Success: connection to topic added.
$ yarp connect topic://aTopic /read
[INFO] |yarp.os.Network| Success: connection to topic added.
$ yarp topic --list
Topics: "/aTopic"
$ yarp name list
registration name /root ip 192.168.1.19 port 10000 type tcp
registration name fallback ip 224.2.1.1 port 10000 type mcast
*** end of message
In a terminal
$ yarp write /write
[INFO] |yarp.os.Port| Port /write active at tcp://192.168.1.19:10003/
>>
In another terminal
$ yarp read /read
[INFO] |yarp.os.Port| Port /read active at tcp://192.168.1.19:10002/
[INFO] |yarp.os.impl.PortCoreInputUnit| Receiving input from /write to /read using tcp
Then, data written on /write
is received on /read
.
yarp.Network.connect('/write','topic://aTopic');
yarp.Network.connect('topic://aTopic','/yarpjsTest/read');
/write
to /read
via a topic /aTopic
, only the connection end to end is visible when querying for the existing connections.
$ yarp exists /write /read
[INFO] |yarp.os.Network| Connection found between /write and /read using carrier tcp
/write
/read
ports only works if we use the prefix topic://aTopic
. Doing:
yarp topic /aTopic
yarp connect /write /aTopic
[ERROR] |yarp.os.Network| Failure: could not find source port /write
doesn't work without the --persit
explicit option.
yarp topic --remove /aTopic
), the persitency of the connection is also removed.yarp diconnect /aTopic /read
or yarp diconnect /write /aTopic
.yarp diconnect /write /aTopic
yarp diconnect /aTopic /read
yarp topic --remove /aTopic
Having this in mind and the fact that Bindings to the class yarp::os::ContactStyle
are not implemented, it seems easier to use topics for creating persistent connections, although the approach using the style
option would be simpler if yarp::os::ContactStyle
was available.
The drawback is that we won't be able to cleanup the topics once we don't need them anymore (unless we run a child process just for that of course, which we should avoid).
It might be worth trying to create the bindings for the class yarp::os::ContactStyle
. If it's not straightforward enough, we'll go for the topics solutions.
It might be worth trying to create the bindings for the class
yarp::os::ContactStyle
. If it's not straightforward enough, we'll go for the topics solutions.
This is probably a bit tricky... although it's worth trying, I'll do it for the next iteration. For a faster closure of the iteration getting the application ready for use by anyone in the team, I'll go with the topic approach (a few lines change in yarp-openmct
.
This is probably a bit tricky... although it's worth trying, I'll do it for the next iteration. For a faster closure of the iteration getting the application ready for use by anyone in the team, I'll go with the topic approach (a few lines change in
yarp-openmct
.
Opened https://github.com/robotology/yarp.js/issues/26 for "persistence" option and related bindings implementation.
Opened https://github.com/ami-iit/yarp-openmct/issues/79 for using the option in the telemetry server.
The disconnection fails for some ports, as well as the subsequent port closure (telemetry server ports). The failure occurs in the yarp.js
module and is reproducible with a minimal Node.js script using yarp.js
functions. As a result, the telemetry server process closure hangs, and the process has to be killed manually.
This seems to be the same issue as #59 . In order to break down the steps leading to the failure, we proceed as follows:
exit
event trigger in yarp.js
=> https://github.com/robotology/yarp.js/blob/b15c8d4a7668eb0cac06a6e3954bb975fcd23b12/yarp.js#L11-L13<CTRL+C>
on the terminal.Unlike the case of a connection between two real Yarp ports, the connection/disconnection to or from a virtual topic is executed asynchronously on Javascript. Inhibiting the exit
event trigger in yarp.js
and applying the other steps mentioned above should let the disconnection to be completed without any closure attempt to interfere.
None of the port connections is closed, which is unexpected at first. Actually, the same behavior is observed when running the commands on the terminal. yarp disconnect --persist /write /read
removes the persistence, but not the connection itself as it keeps active until we explicitly stop it with yarp disconnect /write /read
. Note that running only yarp disconnect /write /read
won't get rid of the persistence.
So when disconnecting a port, we need to do:
yarp.Network.disconnect('/write','topic://aTopic');
yarp.Network.disconnect('topic://aTopic','/read');
yarp.Network.disconnect('/write','/read');
It is needed to have a refresh mechanism of the connections with the Yarp port without having to restart the telemetry server.
Implemented in #80 .