Page 1 of 1

UnsatisfiedLinkError using C3DFileAdapter

Posted: Fri Jan 25, 2019 4:32 am
by sanderholthof
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

Re: UnsatisfiedLinkError using C3DFileAdapter

Posted: Mon Aug 17, 2020 3:05 pm
by bogert
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

Re: UnsatisfiedLinkError using C3DFileAdapter

Posted: Tue Aug 18, 2020 12:55 pm
by mitkof6
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 99 times
Hope this helps.

Re: UnsatisfiedLinkError using C3DFileAdapter

Posted: Tue Aug 18, 2020 1:14 pm
by bogert
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

Re: UnsatisfiedLinkError using C3DFileAdapter

Posted: Thu Aug 20, 2020 3:46 am
by kernalnet
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.

Re: UnsatisfiedLinkError using C3DFileAdapter

Posted: Thu Aug 20, 2020 4:33 am
by mitkof6
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.

Re: UnsatisfiedLinkError using C3DFileAdapter

Posted: Thu Aug 20, 2020 9:56 am
by aymanh
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

Re: UnsatisfiedLinkError using C3DFileAdapter

Posted: Tue Aug 25, 2020 2:26 pm
by bogert
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

Re: UnsatisfiedLinkError using C3DFileAdapter

Posted: Wed Aug 26, 2020 9:49 am
by aymanh
Thanks for the update Ton, much appreciated.

-Ayman