Page 1 of 1

Using the InverseDynamicsSolver function for an OpenSim model with muscles on MATLAB

Posted: Tue Jul 19, 2022 3:48 am
by filo.mace
Dear OpenSim experts,

I am currently using GPOPS on MATLAB to solve an optimization problem to predict a squatting motion. I am using a simple double pendulum model with five muscles on OpenSim 3.3 to represent the lower limbs. The only reason why I include the muscles in the OpenSim model is to measure the musculotendon lengths and moment arms during motion. Then, I enter these measurements in the MATLAB code to compute the contraction dynamics of the muscles.

The program on MATLAB calls a Cpp mex function, that uses the OpenSim InverseDynamicsSolver class to run an inverse dynamics analysis of the double pendulum. The mex function works perfectly when the model doesn't include muscles. However, when I include muscles in the model, the mex file does not work and, MATLAB crashes. Please find attached the Cpp code I am referring to.

So far, I have solved the issue by using the OpenSim model without muscles to run the ID analysis and the one with muscles for everything else. However, I was wondering if there was a way to use this Cpp mex function with the model with muscles as well. Maybe, is this functionality available in later versions of OpenSim?

Thank you very much in advance for your help.

Kind regards,
Filippo

Re: Using the InverseDynamicsSolver function for an OpenSim model with muscles on MATLAB

Posted: Wed Jul 20, 2022 12:31 pm
by ongcf
If muscles are indeed an issue, I'm wondering if you can work around the issue by using `setAppliesForce()` to turn off the force from the muscles. https://simtk.org/api_docs/opensim/api_ ... 2b06b990ee