UnsatisfiedLinkError using C3DFileAdapter

Provide easy-to-use, extensible software for modeling, simulating, controlling, and analyzing the neuromusculoskeletal system.
POST REPLY
User avatar
Sander Holthof
Posts: 2
Joined: Wed Nov 29, 2017 8:15 am

UnsatisfiedLinkError using C3DFileAdapter

Post by Sander Holthof » Fri Jan 25, 2019 4:32 am

Hi,

I'm currently trying to run the C3dexport matlab code (which uses the osimC3D code) to generate trc and mot files from a C3D file. However I keep getting this error:

Error using osimC3D (line 65)
Java exception occurred:
java.lang.UnsatisfiedLinkError: org.opensim.modeling.opensimCommonJNI.new_C3DFileAdapter__SWIG_0()J

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

at org.opensim.modeling.C3DFileAdapter.<init>(C3DFileAdapter.java:41)


Error in c3dExport (line 35)
c3d = osimC3D(c3dpath,1);


From what i can tell from google searching this means something must be wrong with my libraries or paths which means matlab can't define the class C3DFileAdapter. However I followed the standard instructions for connecting opensim to matlab and I've checked that the utilities folder is included in the path. Does anyone know what could be causing this?

I'm using Matlab2018 and Opensim 4.0 on Windows 8.1. This is my first post on the forum please let me know if you require any extra information!

Sander

Tags:

User avatar
Ton van den Bogert
Posts: 166
Joined: Thu Apr 27, 2006 11:37 am

Re: UnsatisfiedLinkError using C3DFileAdapter

Post by Ton van den Bogert » Mon Aug 17, 2020 3:05 pm

I have exactly the same error, so I would like to know if there is a known solution .

Using Opensim 4.1 and Matlab 2019b.

Ton van den Bogert

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

Re: UnsatisfiedLinkError using C3DFileAdapter

Post by Dimitar Stanev » Tue Aug 18, 2020 12:55 pm

Hi,

Probably, you are using scripts that worked with v4.0 and in v4.1 the API changed. I think that in v4.1, you have to follow a slightly different procedure to read a c3d file (code is in Python):

Code: Select all

adapter = opensim.C3DFileAdapter()
static = adapter.read(os.path.join(c3d_dir, static_file))
You can find the scripts that I used attached.
scripts.zip
(7.54 KiB) Downloaded 100 times
Hope this helps.

User avatar
Ton van den Bogert
Posts: 166
Joined: Thu Apr 27, 2006 11:37 am

Re: UnsatisfiedLinkError using C3DFileAdapter

Post by Ton van den Bogert » Tue Aug 18, 2020 1:14 pm

I am using the osimC3D.m script that came with Opensim 4.1:

Code: Select all

>> which osimC3D
C:\Users\Ton\Documents\OpenSim\4.1\Code\Matlab\Utilities\osimC3D.m  % osimC3D constructor
The Opensim 4.1/bin folder is in my Windows path, and I have executed the configureOpensim.m script that came with Opensim 4.1.

I even reinstalled Opensim 4.1 from scratch which made no difference.

When I did this with Opensim 4.0, I ran into the same error, which may be a clue.

The error message is a Java exception:

Code: Select all

Error using osimC3D (line 66)
Java exception occurred:
java.lang.UnsatisfiedLinkError: org.opensim.modeling.opensimCommonJNI.new_C3DFileAdapter__SWIG_0()J

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

	at org.opensim.modeling.C3DFileAdapter.<init>(C3DFileAdapter.java:41)
Ton

User avatar
Mohammadreza Rezaie
Posts: 407
Joined: Fri Nov 24, 2017 12:48 am

Re: UnsatisfiedLinkError using C3DFileAdapter

Post by Mohammadreza Rezaie » Thu Aug 20, 2020 3:46 am

Hi,

I think something is wrong with configuration OpenSim in MATLAB.
Re-run the confugireOpensim.m and restart the MATLAB afterward.

Also, when two different versions of OpenSim exist in the system or user environment path, an error appears. Just keep /Opensim 4.1/bin and remove previous versions from those paths.

Hope this helps.

Regards.

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

Re: UnsatisfiedLinkError using C3DFileAdapter

Post by Dimitar Stanev » Thu Aug 20, 2020 4:33 am

Hi,

Thanks for letting us know. I was just trying to set up Windows and Matlab to test the script.

About the PATH, this makes sense. For example, if you have used OpenSim v.3.3 and then you install v4.1, the PATH variable may have two entries of the /bin folder. If v3.3 is first in the list, Matlab will try loading the dynamic libraries of v3.3 instead of v4.1.

To avoid this, I use Rapid Environment Editor on Windows. You can have multiple entries in the path with both v3.3 and v4.1. What matters is the order (first in the list). To be sure, you can delete all instances of v3.3 and make sure that you have only v4.1's bin.

Also, note that in Rapid Environment Editor you can edit the system variables and the user variables. When OpenSim is installed it adds into the system's PATH variable. This means that you might append the user PATH variable, but the system's PATH variable will be considered with higher priority.

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

Re: UnsatisfiedLinkError using C3DFileAdapter

Post by Ayman Habib » Thu Aug 20, 2020 9:56 am

Thanks Dimitar,

By launching OpenSim 4.1 GUI and typing the following in the scripting window:

Code: Select all

import org.opensim.modeling as osim
c3d = osim.C3DFileAdapter()
methodsview(c3d)
You'll be able to inspect/write/test code that uses the C3DFileAdapter without worry about path setting or wiring to Matlab and you'll find out if the API has changed, and if changed how.

Past that, the issue boils down to wiring Matlab to the correct version. If you have multiple on your system or you have old settings, our configure script tries to clean things up but is not 100% robust. I believe Dimitar addressed some potential pitfalls. I'd just add that our installer does not modify any path variables since this is not required for the GUI/application's operation, users are asked to do that manually to wire Matlab and/or python.

Please let us know if the issue has been resolved so we know if further investigation is needed.

Best regards,
-Ayman

User avatar
Ton van den Bogert
Posts: 166
Joined: Thu Apr 27, 2006 11:37 am

Re: UnsatisfiedLinkError using C3DFileAdapter

Post by Ton van den Bogert » Tue Aug 25, 2020 2:26 pm

Thanks for all the hints.

I had Opensim 3.3, 4.0, and 4.1 installed. I had already made sure that only one Opensim /bin folder was in the path.

There was an OPENSIM_HOME environment variable that pointed to Opensim 3.3. After I deleted that one, the Matlab API for Opensim 4.0 was working.

Now my Opensim 3.3 project probably won't work anymore, but I will be able to fix that.

Ton

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

Re: UnsatisfiedLinkError using C3DFileAdapter

Post by Ayman Habib » Wed Aug 26, 2020 9:49 am

Thanks for the update Ton, much appreciated.

-Ayman

POST REPLY