Page 1 of 2

MATLAB accessibility of SimBody methods in OpenSim 4.0

Posted: Mon Oct 23, 2017 3:55 pm
by hkimpara
Hello,

We used several methods of SimBody APIs to control our OpenSim model.

The functions we used in C++ programming were like followings:
  • _model->getMultibodySystem().realize
    _model->getMatterSubsystem().calcResidualForceIgnoringConstraints
    _model->getMatterSubsystem().multiplyBySystemJacobianTranspose
    _model->getMatterSubsystem().calcM
    _model->getForceSet

    MobilizedBody& findFrameTransforminGround
    MobilizedBody& findFrameVelocityInGround
    _model->getMatterSubsystem().calcStationJacobian
    _model->getMatterSubsystem().calcFrameJacobian
    _model->getMatterSubsystem().multiplyByMInv
    _model->getMatterSubsystem().calcBiasForStationJacobian
    _model->getMatterSubsystem().calcBiasForFrameJacobian
In case of OpenSim 4.0, can we use them directly from MATLAB? Or do we need to still think about keeping C++ programming between MATLAB and SimBody APIs?
Unfortunately, we have not succeeded in MEX programing until today.

Thank you
Hide

Re: MATLAB accessibility of SimBody methods in OpenSim 4.0

Posted: Mon Oct 23, 2017 4:08 pm
by tkuchida
You can call methodsview(Model) in MATLAB to see which methods have been "wrapped" (are accessible through MATLAB) for the Model class. In case you need it, the doxygen documentation for the latest build of 4.0 can be found here: http://myosin.sourceforge.net/1978/.

Re: MATLAB accessibility of SimBody methods in OpenSim 4.0

Posted: Mon Oct 23, 2017 5:05 pm
by chrisdembia
Many of these methods should be available. See here for an example: https://github.com/opensim-org/opensim- ... tSimbody.m

Re: MATLAB accessibility of SimBody methods in OpenSim 4.0

Posted: Mon Oct 23, 2017 5:06 pm
by hkimpara
Hi Tom,

Thank you for your quick response.
I changed path files of MATLAB. Then there is no error on "import org.opensim.modeling.*". However, if I try to read some models using Model('aaa.osim'), error happens with pop-up message saying "Required library failed to load. Check that the dynamic library osimJavaJNI is in your PATH java.lang.UnsatisfiedLinkError: C:\opensim-core\bin\osimJavaJNI.dll: The specified procedure could not be found".

Then another error message comes on Command Window:

Code: Select all

Java exception occurred:
java.lang.UnsatisfiedLinkError:
org.opensim.modeling.opensimSimulationJNI.new_Model__SWIG_1(Ljava/lang/String;)J

	at org.opensim.modeling.opensimSimulationJNI.new_Model__SWIG_1(Native Method)

	at org.opensim.modeling.Model.<init>(Model.java:783)
Do you have any solutions?

Thank you,
Hide

Re: MATLAB accessibility of SimBody methods in OpenSim 4.0

Posted: Mon Oct 23, 2017 5:20 pm
by kenechukwu
Hello Chris,
chrisdembia wrote:Many of these methods should be available. See here for an example: https://github.com/opensim-org/opensim- ... tSimbody.m
I'm absolutely delighted to see that we have access to Simbody methods now from MATLAB, great addition!

Is there some documentation for MATLAB API? It would be very helpful to have a way to 'look-up' corresponding methods and functions from Simbody.

Thanks again,

Kenechukwu

Re: MATLAB accessibility of SimBody methods in OpenSim 4.0

Posted: Mon Oct 23, 2017 10:38 pm
by tkuchida
Hide: Do you have any solutions?
I would need a lot more information to diagnose the issue. I suggest discussing the issue in your meeting tomorrow so you can work out the details in real time. Assuming the Windows PATH environment variable is correct and MATLAB has been properly configured, perhaps you built OpenSim 4.0 from source but didn't check the box in CMake to build bindings?
Kenechukwu: Is there some documentation for MATLAB API?
Although not all methods are available from MATLAB, you can still use the doxygen documentation as a reference. Here's the documentation for the most recent build of 4.0: http://myosin.sourceforge.net/1978/.

Re: MATLAB accessibility of SimBody methods in OpenSim 4.0

Posted: Mon Oct 23, 2017 11:48 pm
by aymanh
Hi,

The message "The specified procedure could not be found" suggests that the library in question was located indeed but it is missing some symbols that the Java bindings are refereing to. This likely is due to the JNI library being loaded not consistent with the java class files. Make sure you have only one installation of OpenSim on your machine, or if more than one make sure the one you want to use is at the front of the Path and is used by Matlab.

Hope this helps,
-Ayman

Re: MATLAB accessibility of SimBody methods in OpenSim 4.0

Posted: Tue Oct 24, 2017 12:30 am
by chrisdembia
It sounds like you've built from source. If you run the OpenSim tests (in Visual Studio, this is the RUN_TESTS or RUN_TESTS_PARALLEL project; from the command-line, you can use ctest; see the README for more information), you should see some MATLAB tests are run. Do those pass? If so, that tells you that you *can* get the environment working properly, but that there are just some configuration issues (PATH, etc.).

Re: MATLAB accessibility of SimBody methods in OpenSim 4.0

Posted: Tue Oct 24, 2017 5:33 am
by hkimpara
Dear Tom, Ayman, and Christopher,

Now I solved! :D

Code: Select all

org.opensim.modeling.opensimCommon.GetVersion()
 
ans =
 
4.0
I believe the main reason would be PATH for MATLAB. I installed R2016a and R2016b. Since I mostly used R2016a, I deleted PATH for R2016b. But I found OpenSim 4.0 recognized R2016b as the MATLAB during the intall.
So, I add PATH for R2016b, then it works!

Thank you so much for the kind supports!
Now we concentrate on accessibility from MATLAB to methods of force and position feedback controls.


Thank you,
Hide

Re: MATLAB accessibility of SimBody methods in OpenSim 4.0

Posted: Tue Oct 24, 2017 10:03 am
by chrisdembia
:)