Provide easy-to-use, extensible software for modeling, simulating, controlling, and analyzing the neuromusculoskeletal system.
-
Mohammadreza Rezaie
- Posts: 412
- Joined: Fri Nov 24, 2017 12:48 am
Post
by Mohammadreza Rezaie » Thu Feb 24, 2022 7:14 am
Dear Experts,
I'm interested in calculating 3D moment and power for each joint in Inverse method even if no coordinate has been defined for two axes (e.g. ankle or knee joint). (I know how to define a new coordinate for each axis and get moment from ID, and calculate power by the product of joint moment and angular velocity)
I was directed to
calcPower() and
calcReactionOnChildExpressedInGround() functions. But I'm not familiar with them. Based on this example:
https://github.com/opensim-org/opensim- ... example.py
I got the state file from IK output using StateReporter tool and adjusted the script for my purpose as follows:
Code: Select all
model = osim.Model('subject_scaled_walk.osim')
joint = model.getJointSet().get('ankle_r')
statesTable = osim.TimeSeriesTable('subject_scale_walk_StatesReporter_states.sto')
statesTraj = osim.StatesTrajectory.createFromStatesTable(model, statesTable)
model.initSystem()
for i in range(statesTraj.getSize()):
state = statesTraj[i]
model.realizeAcceleration(state)
reaction = joint.calcReactionOnParentExpressedInGround(state) # ([0]: moment, [1]: force)
print(reaction.get(0))
The results are NaN for each frame.
My questions are: where should I add the external load file? Is it a correct way for my purpose?
Any help is much appreciated.
Best regards,
Mohammadreza
Tags:
-
Carmichael Ong
- Posts: 401
- Joined: Fri Feb 24, 2012 11:50 am
Post
by Carmichael Ong » Mon Feb 28, 2022 11:21 am
For power, if there's no degree of freedom, then I would expect there to be 0 velocity for that coordinate and thus no power.
For moment, calcReactionOnChildExpressedInGround() should work. This is what JointReaction analysis does, so depending on your workflow, you could attach this analysis to get what you're looking for. If you're trying to implement this in the API for your own workflow, it might also be helpful to look at the code for JointReaction as well (though it's a bit more involved than the simpler example):
https://github.com/opensim-org/opensim- ... n.cpp#L546
-
Mohammadreza Rezaie
- Posts: 412
- Joined: Fri Nov 24, 2017 12:48 am
Post
by Mohammadreza Rezaie » Wed Mar 02, 2022 3:08 am
Hi again,
Following my previous post (
viewtopicPhpbb.php?f=91&t=14425&p=0&sta ... 3d12c24470), I also tried OutputReporter to get 3D joint moment (e.g. ankle):
jointset/ankle_r|reaction_on_child
The results of both OutputReporter and JointReaction are identical but differ from ID. I only used IK output and external load file. Do these tools need any extra input in order to export identical output with ID?
Any help is much appreciated.
MrR