Your first run

This section describes basic use of the URBI engine for Webots.

URBI worlds

We provide a set of example worlds with several robots you will be able to control through URBI. They are located in the directory: WEBOTS_DIRECTORY/projects/packages/urbi/worlds/ . Open the world named aibo_ers7_urbi_soccer.wbt. The image bellow is a screenshot of this world. You can see an aibo in a soccer field, with a pink ball in front of it.

If you look in Webots scene tree, you will see that the aibo (real name is ERS7) is a CustomRobot node, and that it uses urbi as controller.

Let's see how this controller let you control the robot.

URBI controller

You have two ways to control your robot through the URBI controller. The first way is by remotely sending commands to the URBI controller. The URBI controller act as a server, and let you connect to it through the network, and then send URBI commands to this server. The second way is by writing URBI scripts that will be loaded at controller start up.

Send commands with a client software

In order to connect to the URBI controller and then send commands, you need to use a client software that allows you to connect on some address on the network and let you send data through this connection. The simplest program which do this is the telnet program, available on all platform (Windows, Linux and MacOs). You can also use one of the program available at Urbiforge (http://www.urbiforge.com) in the Tool section. The URBI controller launched with the aibo_er7_urbi_soccer world is waiting for connections coming on your computer, on port 54000. So to connect on it you will have to specify the address of your computer ('localhost') and the right port (54000).

Telnet

Windows

To launch telnet under windows click on the start menu, and then on run.

Type cmd and click OK. This will launch a dos command prompt.

In the dos command prompt type telnet localhost 54000.

This launch telnet. It connect to the URBI controller, and the URBI controller send you the URBI header (the lines that display on the screen). On windows the text is badly displayed because of some character conversion problem. It is still usable even if it is not really convenient.

Linux and MacOs

Open a new shell and type telnet localhost 54000. This launch telnet. It connect to the URBI controller, and the URBI controller send you the Urbi header.

Use telnet to send commands

Now that you are connected to the URBI controller, you can send command to it and makes your robot move and interact with it's environment. For example try typing the following commands in telnet:

headPan = 50 time: 5s;
headPan = -50 time: 5s;
headPan = 0 time: 5s;
	

And you will see the head of the aibo move left, right, and then to the center.

Load URBI programs at controller start

By adding the file as argument of the URBI controller

It is possible to write some URBI script and load it at controller startup. To do this just write URBI code in some file, and then specify it's path in the controllerArgs webots node. For example create a new text file, rename it test.u and write in it:

robot.sit (),
      

Then edit the webots world aibo_ers7_urbi_soccer.wbt, and add the path of your file test.u on the line of the controllerArgs node.

controllerArgs "-f -p 54000 32 [HERE ADD YOUR SCRIPT FILES]"
      

For exemple let say that you created your file in

  • C:/Program Files/webots/projects/packages/urbi/data/aibo/ (under Windows)
  • /Applications/webots/projects/packages/urbi/data/aibo/ (under Macos)
  • /usr/local/webots/projects/packages/urbi/data/aibo/ (under Linux)

Then you can specify the path to your file in a absolute form:

  • C:/Program Files/webots/projects/packages/urbi/data/aibo/test.u (under Windows)
  • /Applications/webots/projects/packages/urbi/data/aibo/test.u (under Macos)
  • /usr/local/webots/projects/packages/urbi/data/aibo/test.u (under Linux)

Or you can specify it's path relativelly to the Urbi controller location. Let say that you are using the Urbi controller located here:

  • C:/Program Files/webots/projects/default/controllers/urbi/urbi (under Windows)
  • /Applications/webots/projects/default/controllers/urbi/urbi (under Macos)
  • /usr/local/webots/projects/default/controllers/urbi/urbi (under Linux).

Then the path to your file relatively to the Urbi controller is:

  • ../../../packages/urbi/data/aibo/test.u (under Windows|Linux|Macos)

Add this path to the controllerArgs line and it gives:

# Under Windows, absolute path version:
controllerArgs "-f -p 54000 50 \"C:/Program Files/webots/projects/packages/urbi/data/aibo/test.u\""
(note the use of \" \" about the path, which are mandatory if the path
contains spaces. Here between Program and Files)

# Under MacOs, absolute path version:
controllerArgs "-f -p 54000 50 /Applications/webots/projects/packages/urbi/data/aibo/test.u"

# Under Linux, absolute path version:
controllerArgs "-f -p 54000 50 /usr/local/webots/projects/packages/urbi/data/aibo/test.u"

# Relative path version (os independant)
controllerArgs "-f -p 54000 50 ../../../packages/urbi/data/aibo/test.u"
      

NB: If you have some spaces in your file path, you have to add backslashed double quotes in order to have webots and Urbi understand the path correctly.

Now when you launch Webots and you open the world aibo_ers7_urbi_soccer.wbt you can verify that the controllerArgs was correctly updated.

And if you look at the world view, you can see that the controller has executed the URBI code you specified: the aibo has sat.

By loading the file in URBI.ini

By default, we don't specify files on the Webots controllerArg line. We specify directories. At startup, the URBI controller will go through these directories and try to find a file named URBI.ini. This is a special file containing URBI code which is always loaded at start up by the URBI controller. So another way to load your custom URBI code at start up is to use the command 'load'. Take the test.u file we created in the previous section and move it to the folder containing the URBI.ini file. Then open URBI.ini and add at the end of the file:

      load ("test.u");
      
Now launch Webots and open the world using the URBI controller loading the URBI.ini you just updated, and you will see that your code has been loaded too.