Sending URBI commands

The method send is the simplest way to send commands to the URBI server. It accepts a syntax similmar to the printf function. To send a sequence of commands without risk of having an other thread sending commands at the same time, the lockSend and unlockSend methods can be used to lock and then unlock the send buffer.

int sleeptime = 50;

client->send("motoron;");

client->lockSend(); //send() call by other threads will be blocked from this 
					//point until unlockSend is called

for (float val=0; val<=1; val+=0.05)
    client->send("neck.val = %f;wait (%d);", val, sleeptime);

client->unlockSend();

Alternatively, the UClient class inherits from ostreaam, so you can use the << operator:

 client << "headPan.val = " <<12 << urbi::comma;

The constants 'comma', 'semicolon', 'pipe' and 'parallel' are defined in the urbi namespace for ',', ';', '|' and '&' respectively.

A third possible way is to use the URBI macro, which uses the default connection (the first connection created with your program):

 URBI((
   headPan.val = 12 ,
   echo "coucou" | speaker.play("test.wav") & leds.val = 1
   ));
 //note the absence of double-quotes to delimit the URBI code
 //the double-parenthesis are required
 URBI() << "headPan.val = " << 12 <<  urbi::semicolon;

The function urbi::setDefaultClientUClient *cl) can be used to change the default client.