Matlab API of OpenSim 4.0 on Linux (Ubuntu)

Provide easy-to-use, extensible software for modeling, simulating, controlling, and analyzing the neuromusculoskeletal system.
User avatar
Bart van Veen
Posts: 9
Joined: Tue Jun 23, 2015 5:40 am

Matlab API of OpenSim 4.0 on Linux (Ubuntu)

Post by Bart van Veen » Thu Nov 10, 2016 11:32 am

Hi all,

Since the OpenSim 3 versions come without Java wrapping for the Linux releases, I gave OpenSim 4.0 a go in order to be able to use OpenSim through Matlab on Linux.

The building and the installation of the dependencies was all fine.

The building of the OpenSim package seems to go smooth as well. However, when I run the tests it fails one of 90 tests: the Matlab_ConnectorsInputsOutputs test. If I then continue and install the package and try to initialize a model through matlab, (not surprisingly) it gives a Java exception (printscreens attached). I checked and the configuration of Matlab succeeded (in classpath.txt, librarypath.txt and the matlab path).

Maybe it helps to say that initially all Matlab tests failed, after which I reinstalled Matlab in the home directory (such that I as a user had write access to the installation folder) and rebuild the OpenSim package. I didn't rebuild the dependencies, as everything with that installation seems to be fine.

The error message in the command window suggests that the path is not set correctly or that the required file does not exist, but the path is set correctly and the necessary files exist.

I realize that there is no official release yet on OpenSim 4.0, but I would really appreciate any help on this.

Thanks in advance.

Bart

ps. I am running Matlab 2015b and have downloaded Opensim from the Github master.
Attachments
OpenSimError1.png
OpenSimError1.png (112.58 KiB) Viewed 1873 times
OpenSimError2.png
OpenSimError2.png (95.49 KiB) Viewed 1873 times

User avatar
Ayman Habib
Posts: 2248
Joined: Fri Apr 01, 2005 12:24 pm

Re: Matlab API of OpenSim 4.0 on Linux (Ubuntu)

Post by Ayman Habib » Thu Nov 10, 2016 11:44 am

Hi Bart,

While what you're trying is not supported yet, it's great that you're giving that a shot and it will definitely help us knwo about installation issues if they do exist.

The message suggests that the library itself (osimJavaJNI) was found but that some other libraries that osimJavaJNI depends on could not be found. Possible culprits:
- Simbody related libraries (how do you expect these to be found/loaded).
- lapack low level libraries that simbody depends on.
- Are you building with BTK? if so, how do you expect the library to be found/loaded.
- possibly some run time libraries that were linked during the build but not available during loading from Matlab.

You could use the 'ldd' command on linux to find dependencies on the osimJavaJNI library and see what you get.

Best of luck and please let us know what you find.

Best regards,
-Ayman

User avatar
Christopher Dembia
Posts: 506
Joined: Fri Oct 12, 2012 4:09 pm

Re: Matlab API of OpenSim 4.0 on Linux (Ubuntu)

Post by Christopher Dembia » Thu Nov 10, 2016 11:56 am

What did you set LD_LIBRARY_PATH to?

User avatar
Christopher Dembia
Posts: 506
Joined: Fri Oct 12, 2012 4:09 pm

Re: Matlab API of OpenSim 4.0 on Linux (Ubuntu)

Post by Christopher Dembia » Thu Nov 10, 2016 12:01 pm

The error you show in the screenshot only makes sense to me if *all* tests are failing, not just Matlab_ConnectorsInputsOutputs. Does this mean you were able to resolve the error in the screenshot?

User avatar
Bart van Veen
Posts: 9
Joined: Tue Jun 23, 2015 5:40 am

Re: Matlab API of OpenSim 4.0 on Linux (Ubuntu)

Post by Bart van Veen » Thu Nov 10, 2016 12:14 pm

Hi Ayman and Christopher,

Thanks for your replies. What you're saying makes sense, Ayman, so it might be worth rebuilding the OpenSim dependencies as well in order to prevent any links with the older installation of Matlab?

I'll try to answer your questions below:

- The output of the ldd request is printed below. Seems like none of the necessary links are set/found. All the libraries are present in the installation folder though.

Code: Select all

ldd ./lib/libosimJavaJNI.so
	linux-vdso.so.1 =>  (0x00007ffded789000)
	libosimTools.so => not found
	libosimSimmFileWriter.so => not found
	libosimAnalyses.so => not found
	libosimActuators.so => not found
	libosimSimulation.so => not found
	libosimCommon.so => not found
	libosimLepton.so => not found
	libSimTKsimbody.so.3.6 => not found
	libSimTKmath.so.3.6 => not found
	libSimTKcommon.so.3.6 => not found
	libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007fbac3524000)
	libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007fbac31a2000)
	libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007fbac2e99000)
	libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007fbac2c82000)
	libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fbac28b9000)
	/lib64/ld-linux-x86-64.so.2 (0x000055c8a993f000)
- The LD_LIBRARY_PATH is set to ~/opensim-core/lib

- The error in the screenshots still occurs, but only the Matlab_ConnectorsInputsOutputs test fails, all the other tests pass.

User avatar
Christopher Dembia
Posts: 506
Joined: Fri Oct 12, 2012 4:09 pm

Re: Matlab API of OpenSim 4.0 on Linux (Ubuntu)

Post by Christopher Dembia » Thu Nov 10, 2016 12:58 pm

I would think the libraries are in ~/opensim-core/lib/x86_64-linux-gnu, not ~/opensim-core/lib.

User avatar
Bart van Veen
Posts: 9
Joined: Tue Jun 23, 2015 5:40 am

Re: Matlab API of OpenSim 4.0 on Linux (Ubuntu)

Post by Bart van Veen » Thu Nov 10, 2016 1:09 pm

Hi Christopher,

All the libraries as listed in the ldd output are in ~/opensim-core/lib. The reason I didn't rebuild the dependency packages yet, is that I suspect the problem to have something to do with the OpenSim libraries. From the error message it seems to struggle with finding the osimTools.so library, which is just in the ~/opensim-core/lib directory. This comes down to the point where I gave up and decided to post on the forum.

Any ideas on what could be wrong?

Cheers

User avatar
Bart van Veen
Posts: 9
Joined: Tue Jun 23, 2015 5:40 am

Re: Matlab API of OpenSim 4.0 on Linux (Ubuntu)

Post by Bart van Veen » Thu Nov 10, 2016 7:06 pm

I've recompiled and reinstalled all the dependencies and the opensim package.

Still, the Matlab_ConnectorsInputsOutputs test is the only one to fail.

The ldd output is as follows:

Code: Select all

ldd ./libosimJavaJNI.so
	linux-vdso.so.1 =>  (0x00007ffcb9395000)
	libosimTools.so (0x00007f402f9be000)
	libosimSimmFileWriter.so (0x00007f402f793000)
	libosimAnalyses.so (0x00007f402f4a5000)
	libosimActuators.so (0x00007f402f121000)
	libosimSimulation.so (0x00007f402e90d000)
	libosimCommon.so (0x00007f402e3d8000)
	libosimLepton.so (0x00007f402e19f000)
	libSimTKsimbody.so.3.6 (0x00007f402dacb000)
	libSimTKmath.so.3.6 (0x00007f402d461000)
	libSimTKcommon.so.3.6 (0x00007f402cee5000)
	libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f402cca5000)
	libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f402c923000)
	libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f402c61a000)
	libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f402c403000)
	libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f402c03a000)
	liblapack.so.3 => /usr/lib/liblapack.so.3 (0x00007f402b842000)
	libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f402b63d000)
	librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007f402b435000)
	libblas.so.3 => /usr/lib/libblas.so.3 (0x00007f402b1c5000)
	/lib64/ld-linux-x86-64.so.2 (0x000056480f05b000)
	libgfortran.so.3 => /usr/lib/x86_64-linux-gnu/libgfortran.so.3 (0x00007f402ae9a000)
	libquadmath.so.0 => /usr/lib/x86_64-linux-gnu/libquadmath.so.0 (0x00007f402ac5a000)
And the error that is given when trying to initialize a model is similar to the one in the screenshots, but it now says that it can't find
libSimTKcommon.so.3.6. When closing the error window, the following error is printed in the command window:

Code: Select all

Java exception occurred:
java.lang.UnsatisfiedLinkError: org.opensim.modeling.opensimModelSimulationJNI.new_Model__SWIG_0()J
	at org.opensim.modeling.opensimModelSimulationJNI.new_Model__SWIG_0(Native Method)
	at org.opensim.modeling.Model.<init>(Model.java:819)
It seems like it's getting closer, but I'm even more lost on possible actions than before.

Any suggestions would be really appreciated.

Thanks in advance,

Bart

User avatar
Christopher Dembia
Posts: 506
Joined: Fri Oct 12, 2012 4:09 pm

Re: Matlab API of OpenSim 4.0 on Linux (Ubuntu)

Post by Christopher Dembia » Thu Nov 10, 2016 9:57 pm

It is very suspicious that only one of the MATLAB tests is failing with that error. If the other 3 MATLAB tests are passing, that means that you are likely able to go ahead and use the MATLAB bindings.

1. Open MATLAB and run

Code: Select all

cd <opensim-4.0-install-dir>/sdk/Scripts/Matlab; configureOpenSim;
2. Exit MATLAB.

3. In a terminal window, run

Code: Select all

export LD_LIBRARY_PATH=<opensim-4.0-install-dir>/lib/[x86_64-linux-gnu]
4. Start MATLAB in that same terminal window and try using the OpenSim bindings:

Code: Select all

import org.opensim.modeling.*; m = Model(); 
For the above to work, it is important that you did not manually rearrange the files in the OpenSim installation.

User avatar
Bart van Veen
Posts: 9
Joined: Tue Jun 23, 2015 5:40 am

Re: Matlab API of OpenSim 4.0 on Linux (Ubuntu)

Post by Bart van Veen » Fri Nov 11, 2016 9:24 am

Thank you for your suggestions so far, Chris.

The script to configure OpenSim in Matlab is located in a different folder in my installation. It is in opensim-4.0-install-dir>/share/doc/OpenSim/Scripts. Also, I don't have the <opensim-4.0-install-dir>/lib/[x86_64-linux-gnu] directory.

I didn't rearrange any of the OpenSim install files. I precisely followed the instructions on the opensim-core Github and downloaded the files as a zip from the opensim-core master branch.

The only difference from the install instruction Is the SWIG version. Is it necessary that the version of SWIG is 3.0.6? I have 3.0.8 installed, as it is the only SWIG 3 version available through Synaptic Package Manager (and I had it already installed) and on the SWIG website only 3.0.10 is available (if I'm not mistaking).

When I configure OpenSim through the available scripts, all filepaths are set as in your suggestions from a previous post.

POST REPLY