Webots User Guide

previous page go up next page

Foreword

Thanks

1. Installing Webots

2. Getting Started with Webots

3. Sample Webots Applications

4. Tutorial: Modeling and simulating your robot

5. Programming Controllers and Plugins

6. Using the e-puck robot

     

5.14 Interfacing Webots to third party software with TCP/IP

5.14.1 Overview

If you don't want to develop your robot controllers using C, C++, Java or Python, it is possible to interface Webots to almost any third party software, such as MatLabTM, LispTM, LabViewTM, etc. Such an interface can be implemented through a TCP/IP protocol that you can define yourself. Another option, with MatLabTM, is to use the MatLab C programming interface (see next section). Webots comes with an example of interfacing a simulated Khepera robot via TCP/IP to any third party program able to read from and write to a TCP/IP connection. This example world is called khepera_tcpip.wbt, and can be found in the projects / robots / khepera / worlds directory of Webots. The simulated Khepera robot is controlled by the tcpip controller which is in the controllers directory of the same project. This small C controller comes with full source code in tcpip.c, so that you can modify it to suit your needs. A client example is provided in client.c. This client may be used as a model to write a similar client using the programming language of your third party software. This has already been implemented in Lisp and MatLab by some Webots users.

5.14.2 Main advantages

There are several advantages of using such an interface. First, you can have several simulated robots in the same world using several instances of the same tcpip controller, each using a different TCP/IP port, thus allowing your third party software to control several robots through several TCP/IP connections. To allow the tcpip process to open a different port depending on the controlled robot, you should give a different name to each robot and use the robot_get_name() in the tcpip controller to retrieve this name and decide which port to open for each robot.

The second advantage is that you can also remotely control a real Khepera robot from your third party software without writing a line of code. Simply switching to the remote control mode in the Khepera window will redirect the input/output to the real robot through the serial line.

The third advantage is that you can spread your controller programs over a network of computers. This is especially useful if the controller programs perform computationally expensive algorithms such as genetic algorithms or other learning techniques.

Finally, you should set the controlled robot to synchronous or asynchronous mode depending on whether or not you want the Webots simulator to wait for commands from your controllers. In synchronous mode (with the synchronization field of the robot equal to TRUE), the simulator will wait for commands from your controllers. The controller step defined by the robot_step parameter the tcpip controller will be respected. In asynchronous mode (with the synchronization field of the robot set to FALSE), the simulator will run as fast as possible, without waiting for commands from your controllers. In the latter case, you may want to check the runRealTime field of the WorldInfo node in the scene tree window in order to have a real time simulation in which robots should behave like real robots controlled through an asynchronous connection.

5.14.3 Limitations

The main drawback of TCP/IP interfacing is that if your robot has a camera device, the protocol must send the images to the controller via TCP/IP, which might be network intensive. Hence it is recommended to have a high speed network, or use small resolution camera images, or compress the image data before sending it to the controller. This overhead is negligible if you use a low resolution camera such as the Khepera K213.

5.14.4 MatLabTM TCP/IP toolbox

The standard version of MatLabTM doesn't provide a plain TCP/IP interface. However, a free toolbox called TCP/UDP/IP Toolbox 2.0.5, developed by Mr. Peter Rydesäter, is available. This toolbox can be found on the Webots CD-ROM (in the common / util directory), as well as on the MatLab web site. It is known to run on Windows, Linux and other UNIX systems. It can be used to allow MatLab programs to connect to the tcpip Webots controllers to drive robots.

5.14.5 Gate: a MatLabTM TCP/IP Java interface

A MatLabTM TCP/IP Java interface for Webots called gate was developed and kindly contributed by Mr. Harm Aarts from the Helsinki University of Technology (HUT), Laboratory of Computational Engineering. This package is recommended if you feel more comfortable with Java than C. The package, including documentation, can be found on the Webots CD-ROM in the util subdirectory of the common directory.

previous page go up next page
^ page top ^

  E-mail to webmaster Last updated: Copyright © 2008 Cyberbotics Ltd.