Experimental direct bindings of yarp to Matlab without using Java.
While YARP can already be called from MATLAB using JAVA bindings ( http://www.yarp.it/yarp_swig.html#yarp_swig_matlab ), in this repo we host code for the direct bindings between MATLAB and the C++ YARP interfaces, generated by the experimental SWIG fork with MATLAB support developed by the CasADi project.
Binaries for yarp-matlab-bindings
are available via the robotology
channel, see the robotology-superbuild docs. If you already have conda installed, you can just install it via:
conda install -c conda-forge -c robotology yarp-matlab-bindings
Then start MATLAB in the shell in which the environment is active, and then you should be able to use the YARP MATLAB bindings, for example runnng this example code:
yarpVec = yarp.Vector();
yarpVec.resize(3);
yarpVec.fromMatlab([1;2;3]);
yarpVec.toMatlab()
Make sure that your YARP installation can found by CMake, either installing YARP in the default location or by defining the YARP_DIR
enviromental variable.
Then run the usual cmake + compile + install for this repo. Then add the install location to the matlab path.
Depending on the latest time in which this bindings have been regenerated, the latest YARP version could be compatible with them or not. If you have problem in compilation, you can try to compile the bindings yourself following the instruction in the next section.
To regenerate the bindings, manually run the regenerate-matlab-bindings
GitHub Action.
If you want to regenerate manually the bindings (for example because yarp has been updated and you want to generate bindings for the new version of yarp) you have to install the fork of swig that supports matlab support from https://github.com/robotology-dependencies/swig/ (branch matlab). After that, you have to compile this project enabling the YARP_GENERATE_MATLAB
CMake option.
As the bindings are generated using the yarp.i
from the YARP source repository, you also need to specify the YARP source directory setting the YARP_SOURCE_DIR
CMake variable.
This will generate the bindings in the source directory of the repo, so you can commit the generated sources to the repo.
We try to make sure that the master
branch of this repo stays in sync with YARP master branch, while the stable versioned branch starting from yarp-3.3
branch should remain in sync with the corresponding YARP stable branch, for example yarp-3.3
. However, this autogeneration happens manually, so it is possible that this repo and YARP go out of sync.