robotology/yarp-matlab-bindings

Matlab bindings not working

Closed this issue · 9 comments

@cciliber @GiuliaP @alecive @traversaro

I have followed the instructions in the readme. However, when I open Matlab and try to use the YARP features I get the following error:

>> b=yarp.Bottle
Java exception occurred:
java.lang.NoClassDefFoundError: Could not initialize class yarp.yarpJNI
    at yarp.Bottle.<init>(Bottle.java:63)

How should I proceed?

Thank you.

If you use these bindings, you have to add the parenthesis when you instantiate the Bottle object, like this:
import yarp.Bottle;
b = Bottle();
It is a slightly different syntax from the usual Java bindings, but, apart from this and other minor details, the two are pretty similar. Anyway, we have prepared some examples/tutorials for these bindings as for the Java bindings (e.g. reading/writing a port, communication between RPC client/server, an example usage of the Cartesian Interface, an example of reading from the cameras and processing the images...), that we may commit in the very near future.

In general, if you need to know how to call a specific method, you can look inside the .m files (e.g., in this case, yarp-matlab-bindings/matlab/+yarp/Bottle.m).

Doesn't work anyway.

Executing:

%LoadYarp;
import yarp.Port;
import yarp.Bottle;
import yarp.Network;
import yarp.Stamp;

done=0;

net = Network();
net.init();

port = Port();
%first close the port just in case
port.close();

Yields

Java exception occurred:
java.lang.NoClassDefFoundError: Could not initialize class yarp.yarpJNI
    at yarp.Network.<init>(Network.java:39)

Does it still occur of you re-run Matlab?

Sometime it happened to me also, and re-running Matlab (and maybe YARP related processes) solved the issue. Otherwise, I don't know.

Tried also by restarting yarpserver and doing yarp clean. Doesn't apply.

I have tried to rebuild and reinstall everything from scratch.

When I run this simple example (https://github.com/GiuliaP/icubBMM15/blob/master/matlab/port_examples/yarp_read.m) , now I get this error:

Invalid MEX-file
'/home/kammo/Repos/yarp-matlab-bindings/build/install/mex/yarpMATLAB_wrap.mexa64':
/home/kammo/Repos/yarp-matlab-bindings/build/install/mex/yarpMATLAB_wrap.mexa64: undefined
symbol:
_ZN4yarp2os11NetworkBase16setConnectionQosERKNS0_11ConstStringES4_RKNS0_8QosStyleEb

*** MATLAB has encountered a Linux operating system bug; this bug will eventually cause
MATLAB to crash. Do not repeat the command which produced this error, as doing so might
cause an immediate crash. Save your work and restart MATLAB now.

Thanks to @GiuliaP , who has found the following workaround which apparently works:

Set:

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/kammo/Repos/yarp/build/lib/

In .profile or .bashrc

Can you ldd /home/kammo/bla/bla/bla/yarpMATLAB_wrap.mex64 without the workaround? I suspect that it is linking some old outdated version of the yarp libraries.