Calling yarp from Matlab
Note: these instructions are temporary, things will be changed soon.
Paths such as "/example/swig" in the rest of this page refer to the YARP source code.
Cmake /example/swig. If Cmake asks about JAVA_INCLUDE_PATH and JAVA_INCLUDE_PATH2 put your $JAVA_JDK_ROOT\include and $JAVA_JDK_ROOT\include\win32 (or similar on Linux). Compile and install the resulting project.
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 otherwise I don't see how Matlab can later find it).
Copy /example/swig/src/*.java to /example/swig/generated_src
Compile all java classes in /example/swig/generated_src:
javac -source 1.3 -target 1.3 *.java
You might find it useful to to add this folder (e.g. example/swig/generated_src) to your CLASSPATH environment variable.
You need to tell Matlab the location of the yarp *.class files. Do this by adding the following line to your classpath.txt:
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
You need to tell Matlab the location of the yarp shared library (e.g. jyarp.dll in windows and libjyarp.so in linux) file. Do this by adding the following line to your classpath.txt:
You can ask Matlab about the location of your librarypath.txt by typing
Now the next time you run matlab you should be able to call yarp code.
For example try:
LoadYarp; //this loads the yarp library and initializes the network b=Bottle; b.fromString('hello from Matlab')
Smarter examples can be found in:
Important: you need to close and run Matlab again every time you change either your classpath.txt file or the .java/.class.