Chapter 3. First moves

Table of Contents

Setting and reading a motor value
Setting speed, time or sinusoidal movements
Discovering variables
General structure for variables
Device values and .val alias
Making "global" variables
Expressions
Lists
Running commands in parallel
Conflicting assignments
Useful device variables and properties
Useful commands

In the following, we will use examples from the Aibo robot, but you can easily transpose them to your particular robot. Each element of the robot (sensors, motors, camera,...) is an object and it has a name. In the Aibo, you have objects for the head motors called headPan and headTilt. The camera object is called camera. In the following will often use the term 'device' to refer to an object that handles some piece of hardware in the robot. We have the camera device, the motor devices, etc.

You can find out what devices are available for your particular robot by checking the associated URBI Doc online documentation (http://www.urbiforge.com/doc), or simply by typing the command group objects;

Setting and reading a motor value

We will make use of the motors in the following, so first of all we have to start them:

motors on;

"motors off" is of course also available and you can on/off any device (or more generally, objects) with "device_name on/off". Now, let's start by moving the headPan motor to 30 degrees:

headPan = 30;

Now, let's ask what is the value of the headPan device:

headPan;
[139464:notag] 30.102466

The server responds with a server message (written in italic font here to make it easier to distinguish it from commands) prefixed by a timestamp and a tag between brackets. Since there is no tag associated to the command in this example, notag is used by default. It is very simple to associate a tag to a command in URBI by prefixing the command with the tag and a colon:

mytag:headPan;
[139464:mytag] 30.102466

The message has now the mytag tag. This will be crucial to know who is sending what when several commands are running in parallel, or to stop commands that are running in the background.

You can try to set different motors, like legRF1 or tailTilt, or play with LEDs like ledF1 or ledBMC, or read sensor values like the distance detector distanceNear or the accelerometer accelX, accelY, accelZ. The syntax is always the same: device = value;.

What is really behind the scene here is not device = value, but device.val = value; which is actually setting the val variable of the device object to 'value'. But to make life simpler for beginners, all devices in aibo have an alias which looks like that:

alias headPan headPan.val

So, you won't see the hidden .val which is not necessary in normal operations and for beginners. You can remove those aliases (which are defined in URBI.INI) with unalias.