Difference between revisions of "Calling yarp from Matlab"

From Wiki for iCub and Friends
Jump to: navigation, search
Line 1: Line 1:
 
Follow these instructions to call yarp code from Matlab:
 
Follow these instructions to call yarp code from Matlab:
  
* yarp side
+
* YARP side
 
Install swig and the Java development environment.
 
Install swig and the Java development environment.
  
Line 7: Line 7:
  
 
Compile all java classes in /example/swig/generated_src:
 
Compile all java classes in /example/swig/generated_src:
java -source 1.3 -target 1.3 *.java
+
  java -source 1.3 -target 1.3 *.java
  
- Matlab side
+
* Matlab side
 
You need to tell Matlab the location of the yarp *.class files. Do this by adding the following line to your classpath.txt:
 
You need to tell Matlab the location of the yarp *.class files. Do this by adding the following line to your classpath.txt:
  
yarp_root\\example\\swig\\generated_src
+
  yarp_root\\example\\swig\\generated_src
  
 
where yarp_root should be substituted with the actual path. Maybe it is possible to change this to point to your YARP_ROOT env variable, if you have defined one. I did not have the time to look at it.
 
where yarp_root should be substituted with the actual path. Maybe it is possible to change this to point to your YARP_ROOT env variable, if you have defined one. I did not have the time to look at it.
Line 18: Line 18:
 
You can ask Matlab about the location of your classpath.txt by typing which classpath.txt (usually C:\MATLAB6p5\toolbox\local\).
 
You can ask Matlab about the location of your classpath.txt by typing which classpath.txt (usually C:\MATLAB6p5\toolbox\local\).
  
Now the next time you run matlab you should be able to call yarp code. Try for example b=bottle to create a bottle object.
+
Now the next time you run matlab you should be able to call yarp code. Try for example:
 +
 
 +
  b=bottle to create a bottle object.
  
 
Important: you need to close and run Matlab again every time you change either your classpath.txt file or the .java/.class.
 
Important: you need to close and run Matlab again every time you change either your classpath.txt file or the .java/.class.
  
which classpath.txt
+
  which classpath.txt

Revision as of 12:36, 29 August 2006

Follow these instructions to call yarp code from Matlab:

  • YARP side

Install swig and the Java development environment.

Cmake /example/swig and compile it. You'll get a bunch of .java files in /generated/src and shared library (e.g. jyarp.dll in windows and libjyarp.so in linux). Copy the shared library to a location that is in your path (not sure about this, but I guess it is required so that Matlab can later find it).

Compile all java classes in /example/swig/generated_src:

  java -source 1.3 -target 1.3 *.java
  • Matlab side

You need to tell Matlab the location of the yarp *.class files. Do this by adding the following line to your classpath.txt:

  yarp_root\\example\\swig\\generated_src

where yarp_root should be substituted with the actual path. Maybe it is possible to change this to point to your YARP_ROOT env variable, if you have defined one. I did not have the time to look at it.

You can ask Matlab about the location of your classpath.txt by typing which classpath.txt (usually C:\MATLAB6p5\toolbox\local\).

Now the next time you run matlab you should be able to call yarp code. Try for example:

  b=bottle to create a bottle object.

Important: you need to close and run Matlab again every time you change either your classpath.txt file or the .java/.class.

  which classpath.txt