URBI is an object oriented language,
based on a prototype approach.
You can define objects in pure URBI, or plug C++ classes called "UObjects" directly in the kernel to add these classes to the language, like a native URBI class. You can even unplug the UObject from the kernel and run it as a remote autonomous application, taking the IP address of the URBI Engine as a parameter.
You get a remote object, and it's completely transparent. That simple.
Objects in URBI: a quick introduction
To define a new object, the keyword class can be used, just like in C++:
| class myclass { var x; function init(var p); function f(); }; |
The constructor is called init in URBI. You can create new prototypes (or "instances") with a familiar C++ like syntax:
| subclass = new myclass (42); |
Nothing really surprising here. subclass inherits from myclass and the init constructor is called. You can also rewire the inheritance hierarchy at runtime with the inherits keyword:
| subclass inherits myotherclass; |
Atrributes and methods of myotherclass will become virtually accessible to subclass.
UObject
The big idea is that you can create classes in C++ and use them in URBI. Suppose you have created a C++ class called colormap. Simply have colormap inherit from UObject, add a few modifications in the class content (see tutorial), and compile it. Then link it to the URBI Engine or dynamically load it at runtime, so that it becomes part of the kernel code. You have now a colormap object available in URBI and you can create instances just as with any other class:
| ball = new colormap (R,G,B); at (ball.visible) echo "I see the ball!"; |
Creating a C++ UObject is very simple. To know more about the process and how to either link it to the URBI Engine or run it as an autonomous remote process, check the online documentation:
Bridges with CORBA or other component architectures
It's easy to extend the UObject approach to other types of remote objects. Let's take the example of CORBA. We can define a UObject called corba whose constructor will take some parameters to identify a CORBA object on the network:
| mycorba = new corba ("address of the corba object"); |
In URBI it is easy to add new methods at runtime to an existing object. The corba.init constructor, written in C++, will check for the CORBA object requested, read the services it offers and dynamically create new methods for the mycorba instance, to bridge these services with URBI method calls.
This principle can be extended to any distributed object architecture: openHRP, RT Middleware, Microsoft Services or your custom architecture. URBI is open.