Why does the addition of muscle affect the results of Inverse Dynamics?

Provide easy-to-use, extensible software for modeling, simulating, controlling, and analyzing the neuromusculoskeletal system.
POST REPLY
User avatar
Jiahao Zhou
Posts: 3
Joined: Mon Jul 18, 2022 8:43 pm

Why does the addition of muscle affect the results of Inverse Dynamics?

Post by Jiahao Zhou » Wed May 10, 2023 3:20 am

Hi,
I have recently been troubled by a very strange phenomenon. When I tried to perform an inverse dynamics calculation on a very simple model (shown below), I found that whether or not I added a muscle actually affected the magnitude of the generalized force output from the inverse dynamics. The model only contains a block with a mass of 1kg, a muscle attached to the block and ground, and a PinJoint connecting the block to the ground. The generalized coordinates of the model are set to be 0 at any moment, i.e., always in a static state. According to the Inverse Dynamics equations, the net joint torque acting about the coordinate axe should be zero. However, the output from OpenSim is not 0. This is really confusing. Could you tell me what is the reason for this deviation?
Any help would be greatly appreciated.

Best regards,
Jiahao Zhou

The codes are as follows:

Code: Select all

%% Import OpenSim libraries
import org.opensim.modeling.*

%% Instantiate an empty model
model = Model();
% Get a reference to the model's ground body
ground = model.getGround();

%% Define Body and Joint in the Model
% Instantiate a Body with mass, inertia, and a display geometry
block1 = Body();
block1.setName('Block1');
block1.setMass(1);
block1.setMassCenter(Vec3(0));
block1.setInertia(Inertia(1,1,1,0,0,0));
% Add display geometry for the block
block1.attachGeometry(Brick(Vec3(0.05)));

% Instantiate Pin Joint that connects the block1 and ground.
joint1 = PinJoint('joint1', ground,Vec3(0),Vec3(0,pi/2,0),block1, Vec3(0), Vec3(0));
coord = joint1.updCoordinate();
coord.setName('r1');
coord.setRange([-pi,pi]);

% Add the block body and joint to the model
model.addBody(block1);
model.addJoint(joint1);

%% Define Muscle in the Model
% Define parameters for a Muscle
maxIsometricForce  = 10;
optimalFiberLength = 0.25;
tendonSlackLength  = 0.1;
pennationAngle = 0.0;

% Instantiate a Muscle
muscle1 = Thelen2003Muscle();
muscle1.setName('muscle1')
muscle1.setMaxIsometricForce(maxIsometricForce)
muscle1.setOptimalFiberLength(optimalFiberLength)
muscle1.setTendonSlackLength(tendonSlackLength);
muscle1.setPennationAngleAtOptimalFiberLength(pennationAngle)

% Add Path points to muscle 1
muscle1.addNewPathPoint('muscle1-point1', ground, Vec3(0.0,0.35,0.05))
muscle1.addNewPathPoint('muscle1-point2', block1, Vec3(-0.05,0.0,0))

% Add the muscle (as force) to the model
model.addForce(muscle1)

%% Finalize connections so that sockets connectees are correctly saved
model.finalizeConnections();

%% Inverse Dynamics
id=InverseDynamicsTool();
id.setModel(model);
id.setCoordinatesFileName('motion.sto'); % the value of coord is 0 in the file 'motion.sto'
id.setStartTime(0.01);
id.setEndTime(0.1);
id.run();
Attachments
simple_model.png
simple_model.png (4.87 KiB) Viewed 686 times

Tags:

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

Re: Why does the addition of muscle affect the results of Inverse Dynamics?

Post by Mohammadreza Rezaie » Wed May 10, 2023 3:10 pm

Hi, I'm not whether this is the solution, try excluding the muscles:

Code: Select all

exclude = ArrayStr();
exclude.set(0, 'Muscles');
id.setExcludedForces(exclude);

User avatar
Jiahao Zhou
Posts: 3
Joined: Mon Jul 18, 2022 8:43 pm

Re: Why does the addition of muscle affect the results of Inverse Dynamics?

Post by Jiahao Zhou » Wed May 10, 2023 10:28 pm

kernalnet wrote:
Wed May 10, 2023 3:10 pm
Hi, I'm not whether this is the solution, try excluding the muscles:

Code: Select all

exclude = ArrayStr();
exclude.set(0, 'Muscles');
id.setExcludedForces(exclude);
Dear Mohammadreza Rezaie:
Thanks for your reply. I have tried replacing the muscle with a PointActuator before and got the correct net joint torque. I am just trying to figure out why the addition of muscle, also as an actuator, would affect the results of the inverse dynamics. If there is such an effect, does it mean that muscles need to be additionally excluded when using the musculoskeletal model for inverse dynamics analysis, but the tutorial documentation on inverse dynamics does not mention this operation. I really want to understand the reason behind this phenomenon, as it would affect my confidence in the inverse dynamics results of OpenSim.

Best,
Jiahao Zhou

User avatar
Carmichael Ong
Posts: 401
Joined: Fri Feb 24, 2012 11:50 am

Re: Why does the addition of muscle affect the results of Inverse Dynamics?

Post by Carmichael Ong » Wed May 17, 2023 10:10 am

Muscles have passive forces if they are longer than a certain length, so they can affect your ID results. More information on muscles can be found here: https://simtk-confluence.stanford.edu:8 ... blications

These have to be excluded, which has to be done by the user if the API is used. In the GUI, this is automatically done here: https://github.com/opensim-org/opensim- ... l.java#L84

POST REPLY