Jacobian / getMatterSubsystem

Provide easy-to-use, extensible software for modeling, simulating, controlling, and analyzing the neuromusculoskeletal system.
POST REPLY
User avatar
Bas de Kruif
Posts: 7
Joined: Tue Sep 15, 2015 4:28 am

Jacobian / getMatterSubsystem

Post by Bas de Kruif » Tue Apr 05, 2016 12:31 am

Hello all,

I try to get the Jacobian of my model from Matlab. This data seems to be available in Matlab as described in the Simbody documentation through the SimbodyMatterSubsystem. However, if I ask for which methods are available, there are only very few methods available:

Code: Select all

>> mss = model.getMatterSubsystem();
>> methods(mss)
Methods for class org.opensim.modeling.SWIGTYPE_p_SimTK__SimbodyMatterSubsystem:
equals     getClass   hashCode   notify     notifyAll  toString   wait       
If I call other functions, I get the error 'Undefined function', which is as expected. Is there a way to call

Code: Select all

void SimTK::SimbodyMatterSubsystem::calcSystemJacobian(const State &state, Matrix &J_G) const
from Matlab?

Thanks for any help!
Bas

User avatar
Maarten Sarens
Posts: 7
Joined: Sat Oct 10, 2015 11:34 am

Re: Jacobian / getMatterSubsystem

Post by Maarten Sarens » Tue Apr 05, 2016 3:18 am

I have a simillar problem as you. I want to call the getMobilizedBody function. I'm trying to resolve the problem. Keep me updated if you find anything

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

Re: Jacobian / getMatterSubsystem

Post by Ayman Habib » Tue Apr 05, 2016 11:26 am

Hi,

The classes in the SimTK namespace (usually low level Simbody classes, qualified in the C++ code and docs by SimTK:: prefix) are mostly unavailable in Matlab except for classes that are used across the OpenSim interface (e.g. State, Vector, Vec3, Transform etc.) as such the class SimTK::MobilizedBody and SimTK::SimbodyMatterSubsystem are not available to scripting as of now. This problem exhibits itself by using class names (SWIG_p_...*). This was done partly to not overwhelm users with so many classes that are considered internal. These classes are available only through the C++ API.

If there's interest in some specific classes we can try to expose them to scripting in the future, so please advise. Keep in mind that exposing a class requires exposure of the types used to interface with it as well which may cause the process to snowball into a much larger set of classes.

It may also help to explain what you're trying to accomplish from Matlab to help decide on the approach or suggest a workaround.

Hope this helps,
-Ayman

User avatar
Bas de Kruif
Posts: 7
Joined: Tue Sep 15, 2015 4:28 am

Re: Jacobian / getMatterSubsystem

Post by Bas de Kruif » Sat Apr 09, 2016 8:37 am

Hello Ayman,

Thanks for your answer. It is always good to understand that I wasn't doing anything wrong, but that the classes were intentionally hidden for the user. I can understand that making a new method available in an API would give a lot other sub-classes that need to be implemented too. I am grateful that I can use this software for my own research. So many thanks for all the work already done!

My previous 'problem' was that I had difficulties with connecting an exoskeleton to the human model. I script this from Matlab so that I can scale the exoskeleton to different users in the future. I should have had enough degrees of freedom to constrain a movement, but OpenSim could not find a feasible solution for an initial state. I wanted to test in which direction I could still move in Cartesian coordinates to understand why the solution could not be found. The Jacobian would be helpful here. I solved how to constraint the movement of the exo, but in the future I think I get similar issues and try to come up with a more systematic approach for coping with it.

Concerning feature requests: for future development I would like to see the information in the MatterSubSystem from the API. Having access to the Jacobian, mass matrix etc. would help me for the design of controllers of exoskeletons, and in the design of the exoskeleton itself.
Thanks
Bas

User avatar
Brad Humphreys
Posts: 79
Joined: Thu Feb 03, 2011 11:32 am

Re: Jacobian / getMatterSubsystem

Post by Brad Humphreys » Sun Apr 10, 2016 7:06 am

Bas,

Availability of the Jacobian is a project that I am interested in; we use it in optimization for predictive modeling. For now we calculate it though using finite differences. Brian Umberger and Leng-Feng Lee wrote a nice paper that does something similar. But even better, they shared the code: https://simtk.org/home/directcolloc/. In it you can find a good example of finite differences Jacobian. (Basically using calculateStateDerivatives and setStates type functions).

Brad

POST REPLY