Getting YARPed

From Wiki for iCub and Friends
Jump to: navigation, search


YARP is a robotics library we will be using at the school. It helps free your code from being overly dependent on your robot hardware and processing setup. It is in a similar spirit to the player/stage project for mobile robots.

Read about YARP here:

Downloading YARP as a Source Package

Download YARP here:

Downloading YARP from CVS

We're updating YARP all the time. If you're adventurous and want to be able to keep up to date easily, you can install YARP from CVS. Follow the instructions at:

with modulename "yarp2" to get the code.

Here's a summary of the commands needed if you have command-line cvs:

 cvs login
 cvs -z3 co -P yarp2

The code should appear in a subdirectory called yarp2. See yarp2/README for compilation tips. One important point: don't put the yarp2 subdirectory in a path that has a directory name containing spaces (e.g. D:\My Documents\yarp2). This causes problems later on. C:\yarp2 works fine.

If you use Microsoft Windows, and don't use Cygwin, we recommend WinCvs (version>=2.0):

 Module name and path on the server: "yarp2"
 Local folder to checkout to: anything you like, for example "c:\yarp2"

On Unix, you probably already have the command line "cvs" program.

If you are a developer (linux or cygwin):

export CVS_RSH=ssh
cvs -z3 co -P yarp2

Compiling YARP

Once you have downloaded YARP, you can compile it using CMake. See the README file in the source code for details. In summary, simply run CMake in the directory YARP is in, check that it finds ACE correctly (and help it if not), and when everything is configured build the code with "make" in Unix or whatever compiler you are using for Windows.

If you are compiling on Windows using MS Visual C, make sure you have compiled YARP as a release version: Build-> Set Active Configuration -> ALL_BUILD - Win32 Release.

Testing YARP

On Unix, you can type "make test" to run some tests.

In the "bin" directory after compilation (possibly under a "debug" or "release" subdirectory) you should find some executables, including one called "yarp" or "yarp.exe".

On Unix, enter the directory containing the yarp executable and put it in your PATH using one of:

 export PATH=$PWD:$PATH
 setenv PATH $PWD:$PATH

On Windows, set the environment variable called PATH to include, e.g., C:\yarp2\bin\release and C:\yarp2\lib\release>. Do this using, e.g. Control Panel -> System -> Advanced -> Environment Variables -> System Variables -> Path -> Edit. Now run cmd.exe or launch the Command Prompt application.

Type "yarp" or "yarp.exe". You should see this message:

 This is the YARP network companion. 
 Call with the argument "help" to see a list of ways to use this program.

If this works, type "yarp check" or "yarp.exe check". You should see:

 yarp: ==================================================================
 yarp: === Trying to register some ports
 yarp: no connection to nameserver
 yarp: no connection to nameserver, scanning mcast
 yarp: Polling for name server (using multicast), try 1 of max 3
 yarp: No response to search for server
 yarp: Polling for name server (using multicast), try 2 of max 3
 yarp: No response to search for server
 yarp: Polling for name server (using multicast), try 3 of max 3
 yarp: No response to search for server
 yarp: === NO NAME SERVER!  Switching to local, fake mode
 yarp: ==================================================================
 yarp: === Trying to connect some ports
 yarp: Receiving input from /tmp/port/2 to /tmp/port/1 using tcp
 yarp: Sending output from /tmp/port/2 to /tmp/port/1 using tcp
 yarp: ==================================================================
 yarp: === Trying to write some data
 yarp: ==================================================================
 yarp: === Trying to read some data
 yarp: *** Read number 42
 yarp: ==================================================================
 yarp: === Trying to close some ports
 yarp: Removing input from /tmp/port/2 to /tmp/port/1
 yarp: Removing output from /tmp/port/2 to /tmp/port/1
 yarp: *** YARP seems okay, but there is no name server available.

Now start four terminals, called A-D. Do the following (where "yarp" may need to be replaced with "yarp.exe"):

 [in terminal A] yarp server
 [in terminal B] yarp check

Terminal B should run some tests, as before, then say yarp is "ok". Now do the following, leaving terminal A untouched:

 [in terminal B] yarp read /read
 [in terminal C] yarp write /write verbatim /read

Now type some stuff into terminal C and hit return. That stuff should be echoed on terminal B. Now try:

 [in terminal D] yarp disconnect /write /read

Now if you type stuff in terminal C, it no longer appears on B. Now try:

 [in terminal D] yarp connect /write /read

Now if you type stuff in terminal C, it appears on B again.

If you've gotten this far, things are looking good!

There's a slightly longer test you might try: It requires that you set the "CREATE_GUIS" and "CREATE_DEVICE_LIBRARY" flags in cmake while compiling (use "ccmake ." to do this on Unix, or just rerun the cmake GUI on windows). Have a look at the README for better instructions.

If you have the "yarpdev" and "yarpview" programs, we can go further. Try:

 [in terminal E] yarpdev --device test_grabber --period 2 --width 8 --height 8 --name /grabber

This creates a test "device" with a port called "/grabber", outputing a very small test image every 2 seconds. You won't see much happen yet. Try:

 [in terminal D] yarpview --name /view &
 [in terminal D] yarp connect /grabber /view

You should now see a slow-moving red line. Try:

 [in terminal D] yarp connect /grabber /read

You should now see a text representation of the image on terminal B appearing every 2 seconds.

This and other examples are in the "example" subdirectory of the source code.


YARP Installation Troubleshooting Tips