Objects grouping

An important feature of URBI is the capacity to group objects into hierarchies. This is done with the group command: group groupname { object1, object2, ...}, for example:

group legLF { legLF1, legLF2, legLF3 };
group legs { legLF, legLH, legRF, legRH };

Figure 4.1. A typical motor device hierarchy

A typical motor device hierarchy

This grouping feature is associated to the notion of "broadcasting", which is used for several things. One is to make multi-object assignments: any assignment is executed for the group and is recursively passed to child subgroups. In other words, using the example above, the command legLF.val = 0 will set the value of legLF1.val, legLF2.val and legLF3.val to 0 (note that aliases work also here if you want).

group ab { a, b };
ab.n = 4;
a << a.n, b << b.n;
[00828842:a] 4.000000
[00828842:b] 4.000000

For any robot, there will usually be a hierarchy of object grouping available at start. This is usually done in the URBI.INI file, or std.u.

For example, with the Aibo, there is a motors group to store all motors and a leds group which contains all led devices. You can easily set every LEDs to a random value with a command like this:

leds = random(2); // alias applies here

For fun, you can run something like: fun: loop leds = random(2), and see the result.

There is more about groups and broadcasting, which is a very powerful feature of URBI. We will come back on this subject in the chapter "Objects in URBI".