Connecting OpenSim 4.1 to Matlab

Provide easy-to-use, extensible software for modeling, simulating, controlling, and analyzing the neuromusculoskeletal system.
POST REPLY
User avatar
Evan Dooley
Posts: 33
Joined: Sun Nov 24, 2019 11:17 am

Connecting OpenSim 4.1 to Matlab

Post by Evan Dooley » Thu May 28, 2020 2:01 pm

Hello,

I am trying to set up scripting with Matlab. I have followed the instructions on the documentation page (https://simtk-confluence.stanford.edu:8 ... ith+Matlab) for both the automated version and the manual way shown. I have also reinstalled OpenSim and made sure all previous versions were uninstalled. No matter what I attempt I always end up with the same error when I try to run the test code:

Code: Select all

org.opensim.modeling.opensimCommon.GetVersion()
Failed to load one or more dynamic libraries for OpenSim.
java.lang.UnsatisfiedLinkError: C:\OpenSim 4.1\bin\osimJavaJNI.dll: Can't find dependent libraries
Make sure OpenSim's bin directory is on your PATH.
See https://simtk-confluence.stanford.edu/display/OpenSim40/Scripting+with+Matlab
Java exception occurred:
java.lang.UnsatisfiedLinkError:
org.opensim.modeling.opensimCommonJNI.GetVersion()Ljava/lang/String;

	at org.opensim.modeling.opensimCommonJNI.GetVersion(Native Method)

	at org.opensim.modeling.opensimCommon.GetVersion(opensimCommon.java:25)
I have ensured that OpenSim's bin directory is on the path for Matlab.

Has anyone seen this before? Is there another way to connect Matlab and OpenSim?

Thanks,
EAD

Tags:

User avatar
Dimitar Stanev
Posts: 1096
Joined: Fri Jan 31, 2014 5:14 am

Re: Connecting OpenSim 4.1 to Matlab

Post by Dimitar Stanev » Fri May 29, 2020 1:09 am

Hi,

You must make sure of the following:

1. Is the osimJavaJNI.dll in the bin folder of OpenSim?
2. Did you add C:\OpenSim 4.1\bin to the system path? This is very important.
3. Did OpenSim and Matlab have the same architecture (e.g., x84 or x64). They should be the same.

User avatar
Evan Dooley
Posts: 33
Joined: Sun Nov 24, 2019 11:17 am

Re: Connecting OpenSim 4.1 to Matlab

Post by Evan Dooley » Fri May 29, 2020 6:49 am

Yes, the file is in the bin folder.

Yes, the bin folder is saved to the Matlab path.

Both OpenSim and Matlab are 64-bit.

Any other ideas?

Thanks,
EAD

User avatar
Evan Dooley
Posts: 33
Joined: Sun Nov 24, 2019 11:17 am

Re: Connecting OpenSim 4.1 to Matlab

Post by Evan Dooley » Fri May 29, 2020 7:06 am

To resolve this issue I had to edit the System Environment Variables list on my computer to include the bin folder for OpenSim.

So full process was:
1. run configureOpenSim.m in Matlab
2. add \bin to Matlab path
3. close Matlab
4. open system environment from start menu
5. edit environment variables to include OpenSim bin folder
6. open Matlab
7. then test code worked

Not sure if this is what more people will have to do, but we had to do it this way for a couple computers in our lab.

Best,
EAD

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

Re: Connecting OpenSim 4.1 to Matlab

Post by Ayman Habib » Fri May 29, 2020 10:48 am

Thanks Emily for reporting back.

The issue is likely that OpenSim is run as a regular user (so is tied to User environment) while Matlab is installed by admin user (so tied to System environment) which are not in sync. You may have been ok if you ran OpenSim as admin but it's hard to know your exact setup/environment.

Glad you got to the bottom of it and hope it helps others who run into this in the future,

Best regards,
-Ayman

POST REPLY