4.7 Using MATLABTM4.7.1 Introduction to MATLABTMMATLABTM is a numerical computing environment and an interpreted programming language. MATLABTM allows easy matrix manipulation, plotting of functions and data, implementation of algorithms and creation of user interfaces. You can get more information on the official MathWorks web site. MATLABTM is widely used in robotics in particular for its Image Processing, Neural Networks and Genetics Algorithms toolboxes. Webots allows to directly use MATLABTM scripts as robot controller programs for your simulations. Using the MATLABTM interface, it becomes easy to visualize controller or supervisor data, for example, processed images, sensor readings, the performance of an optimization algorithm, etc. while the simulation is running. In addition it becomes possible reuse your existing MATLABTM code directly in Webots. 4.7.2 How to run the Examples ?If MATLABTM is already installed, you can directly launch one of the MATLABTM examples. For doing that, start Webots and open the projects/languages/matlab/worlds/e-puck_matlab.wbt or projects/contests/nao_robocup/worlds/nao2_matlab.wbt in your Webots installation directory. Webots automatically starts MATLABTM when it detects an m-file in a controller directory. Note that the m-file must be named after its directory in order to be identified as a controller file by Webots. So for example if the directory is named my_controller, then the controller m-file must be named my_controller/my_controller.m. No special initialization code is necessary in the controller m-file. In fact Webots calls an intermediate launcher.m file that sets up the Webots controller environment and then calls the controller m-file. In particular the launcher.m file loads the library for communicating with Webots and adds the path to API m-files. The MATLABTM API m-files are located in the lib/matlab directory of Webots distribution. These are readable source files; please report any problem, or possible improvement about these files. 4.7.3 MATLABTM InstallationIn order to use MATLABTM controllers in Webots, the MATLABTM software must be installed (The MathWorksTM license required). Webots was tested with MATLABTM R2008b and R2009b, older versions may work but they were not tested and are not supported. Webots must be able to access the matlab executable (usually a script) in order to run controller m-files. Webots looks for the matlab executable in every directory of your PATH (or Path on Windows) environment variable. Note that this is similar to calling matlab from a terminal (or Command Prompt on Windows), therefore, if MATLABTM can be started from a terminal then it can also be started from Webots. On Windows, the MATLABTM installer will normally add MATLABTM's bin directories to your Path environment variable, so usually Webots will usually be able to locate MATLABTM after a standard installation. However in case it does not work, please make sure that your Path contains this directory (or something slightly different, according to you MATLABTM version):
On Linux, the MATLABTM installer does normally propose to add a symlink to the matlab startup script in the /usr/local/bin directory, this is a good option to make matlab globally accessible. Otherwise you can create the link at anytime afterwards with this shell command (please change according to your actual MATLABTM installation directory and version):
4.7.4 Compatibility IssuesNote that a 32-bit version of Webots is not compatible with a 64-bit version of MATLAB and vice-versa. On the Windows and Mac platforms, Webots comes only in 32-bit flavour and therefore it can only inter-operate with a-32 bit version of MATLAB. On Linux, the 32-bit version of Webots can only inter-operate with a 32-bit version of MATLAB and the 64-bit version of Webots can only inter-operate with a 64-bit version of MATLAB. On some platform the MATLAB interface needs perl and gcc to be installed separately. These tools are required because MATLAB's loadlibrary() function will need to recompile Webots header files on the fly. According to MATLAB's documentation this will be the case on 64 bit systems, and hence we advice 64 bit Webots users (on Linux) to make sure that these packages are installed on their systems. On some Mac OS X systems the MATLAB interface will work only if you install the Xcode development environment, because gcc is required. An error message like this one, is a symptom of the above described problem:
4.7.5 Third Party Techniques for Interfacing Webots and MATLABTMThese techniques are developed by third parties and therefore not supported by Cyberbotics. MATLABTM TCP/IP toolboxThe 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 MATLABTM web site. It is known to run on Windows, Linux and other UNIX systems. It can be used to allow MATLABTM programs to connect to the tcpip Webots controllers to drive robots. Gate: a MATLABTM TCP/IP Java interfaceA 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. ![]() ^ page top ^ |
| E-mail to webmaster | Last updated: | Copyright © 2010 Cyberbotics Ltd. |