Page 4 of 6

Re: Using metabolics probe with DeGrooteFregly2016Muscle

Posted: Mon Jul 27, 2020 10:07 am
by chrisdembia
Iris:

I would use "prescribeControlsToModel()" (https://github.com/opensim-org/opensim- ... #L338-L346), then convert the MocoTrajectory/Solution to a StatesTrajectory. Here's a sketch (untested pseudocode) of how you might do this:

Code: Select all

solution = study.solve();
opensimMoco.prescribeControlsToModel(solution, model);
statesTraj = solution.exportToStatesTrajectory(model);
pathAct = PathActuator.safeDownCast(model.getForceSet().get('my_motor'));
ankle_coord = model.getCoordinateSet().get('ankle_angle_r');
for i = 0:statesTraj.getSize() - 1
    state = statesTraj.get(i);
    tension = pathAct.computeActuation(state);
    momarm = pathAct.computeMomentArm(state, ankle_coord);
    disp(momarm * tension);
end

Re: Using metabolics probe with DeGrooteFregly2016Muscle

Posted: Tue Jul 28, 2020 12:32 pm
by irisdrofnm
Thank you Chris! Few questions.

Does the prescribeControlsToModel work with MocoInverse in Matlab? I get the following error: Undefined variable "opensimMoco" or class "opensimMoco.prescribeControlsToModel".

From what I understand, MocoInverse allows writing states to StatesTable while MocoStudy uses StatesTrajectory as suggested in your code. I have problems when trying to use getSize with StatesTable. Is their another way to iterate through StatesTable?

I am trying to understand how this code works for computing tension and moment arm of the PathActuator. From MocoInverse solution, my 'states.sto' file does not include the states for my PathActuator, only muscles. Do I use the force of the PathActuator to compute actuation and moment arm from muscle state?

Thank you,
Iris

Re: Using metabolics probe with DeGrooteFregly2016Muscle

Posted: Mon Aug 03, 2020 5:49 am
by irisdrofnm
Hi again,

I am still struggling with the above, that is, getting the state for my PathActuator to compute the device actuator torque. The actuator does not appear in my MuscleAnalysis. I am using MocoInverse.

Can I assume that the difference between the torque generated by my unassisted muscles and assisted muscles is the device actuator torque? Or is this too simplified?

Thanks all!

Re: Using metabolics probe with DeGrooteFregly2016Muscle

Posted: Mon Aug 03, 2020 9:57 am
by nbianco
Hi Iris,

Your PathActuator is not showing up because it does not derive from the Muscle class, therefore it will not be included in a MuscleAnalysis. You could instead use MocoStudy's analyze() method.
Can I assume that the difference between the torque generated by my unassisted muscles and assisted muscles is the device actuator torque? Or is this too simplified?
This approach would also work, but it might be more work to compute all muscles torques than to just compute the PathActuator torque using analyze().

-Nick

Re: Using metabolics probe with DeGrooteFregly2016Muscle

Posted: Wed Sep 02, 2020 8:05 am
by rosshm
Hi all,

I'm bumping this thread with a related question, sorry if it was answered here already (I didn't see it).

Once I have a Moco solution in the workspace in Matlab, is there a quick/easy way to extract the muscle-by-muscle time series data for fiber velocity (for the purposes of calculating metabolic rates)? I need activation and fiber velocity to do this, activation is easy enough to get (it's a muscle state) but I can't figure out how to extract the fiber velocity data.

Ross

Re: Using metabolics probe with DeGrooteFregly2016Muscle

Posted: Wed Sep 02, 2020 11:40 am
by nbianco
Hi Ross,

I show how to do this in post I made earlier in this thread: viewtopicPhpbb.php?f=1815&t=11538&p=33373&start=0&view=.

-Nick

Re: Using metabolics probe with DeGrooteFregly2016Muscle

Posted: Wed Sep 02, 2020 2:07 pm
by rosshm
Thanks Nick, it looks like I already asked this question (I turn 40 next week, memory is going...)

Re: Using metabolics probe with DeGrooteFregly2016Muscle

Posted: Fri Sep 04, 2020 3:12 pm
by nbianco
Haha, no worries.

We should probably have a documentation page dedicated to analyze() so users don't need to search the forum like this for it.

Re: Using metabolics probe with DeGrooteFregly2016Muscle

Posted: Sat Sep 05, 2020 1:51 pm
by karthick_ganesan
Dear Ross Miller,
I used Umberger2010MetabolicsProbe and calculated the metabolic cost for tracking simulation of your 2D Model. I got it to be 7.9 W/kg. I think it is about 3 W/kg higher for this speed. I am wondering if I am doing something wrong. Do you get similar results?
Thanks,
Karthick.

Re: Using metabolics probe with DeGrooteFregly2016Muscle

Posted: Sat Sep 05, 2020 1:59 pm
by karthick_ganesan
Hi all,
What is the difference between adding a prescribed controller to a model and just including the controls .sto file under controller set in the analysis setup file? Both seems to give the same result. When using the prescribed controller ( i.e, PrescribedController('controls.sto'), should one still include the controls file in the analysis setup also? If done so gives different result. Please let me know.
Thanks,
Karthick.