Yet Another Robot Platform
Both YARP and ROS usually operate with a name server to help track what ports/topics/nodes are where (but see also Using YARP without a name server).
We assume you have ROS's usual name server "roscore" running somewhere. Now, with YARP, you have several options:
For the first option, using "roscore" only, see Using YARP with roscore only. For the third option, using both name servers independently, see Configuring YARP clients to use two nameservers independently. Here we are going to the middle option, where yarpserver is configured to be ROS-aware. Setting this up is simple. Once roscore is running, and ROS_MASTER_URI is correctly set to point to it, do:
You should see lines like these as the server starts up:
.. Using ROS with ROS_MASTER_URI=http://127.0.0.1:11311 ... * register "/ros" xmlrpc "127.0.0.1" 11311 ...
To make sure that everything has worked, start a quick test program in one console:
yarp read /testtopic@/testnode
Then in another do:
rostopic list # /testtopic should be listed rosnode list # /testnode should be listed rostopic pub /testtopic std_msgs/String "Hello YARP" # yarp read should echo this
If instructed, YARP can use ROSCORE's name server (the "roscore" program) rather than its own native name server (the "yarpserver" program). Here's how. First, make sure you have started roscore:
Make sure that the ROS_MASTER_URI environment variable is set as roscore proposes. Now, place YARP in a new namespace, called for example "/ros" itself
yarp namespace /ros
Then ask YARP to detect ROS a nameserver and save its address:
yarp detect --ros --write
This should report something along the lines of:
Trying ROS_MASTER_URI=http://127.0.0.1:11311... Reachable. Writing. Configuration stored. Testing. Looking for name server on 127.0.0.1, port number 11311 If there is a long delay, try: yarp conf --clean ROS Name server /ros is available at ip 127.0.0.1 port 11311
An alternative procedure is to manually configure YARP to use a ROS name server with a particular host name or ip address and port number:
yarp conf icubsrv 11311 ros
YARP ports should be usable at the point. To test this, you could run:
Or try some of the exercises in Getting Started with YARP Ports.
YARP ports should behave as normal. One caveat: the multicast protocol requires some support from the name server that ROSCORE does not currently provide. So don't use multicast if you want to work also with ROS (or use multiple name servers).
YARP has a general ability to use multiple nameservers. The trick is to set up two namespaces, for example /yarp and /ros:
yarp namespace /yarp # Make a YARP namespace yarp detect --write # detect and store contact info for yarpserver yarp namespace /ros # Make a ROS namespace yarp detect --ros --write # detect and store contact info for roscore yarp namespace /yarp /ros # Now select *both* namespaces # queries / registrations now go to *both* YARP and ROS as needed