Using metabolics probe with DeGrooteFregly2016Muscle

OpenSim Moco is a software toolkit to solve optimal control problems with musculoskeletal models defined in OpenSim using the direct collocation method.
User avatar
Christopher Dembia
Posts: 506
Joined: Fri Oct 12, 2012 4:09 pm

Re: Using metabolics probe with DeGrooteFregly2016Muscle

Post by Christopher Dembia » Mon Jul 27, 2020 10:07 am

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

User avatar
Iris Magnusdottir
Posts: 19
Joined: Thu Nov 01, 2018 2:04 am

Re: Using metabolics probe with DeGrooteFregly2016Muscle

Post by Iris Magnusdottir » Tue Jul 28, 2020 12:32 pm

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

User avatar
Iris Magnusdottir
Posts: 19
Joined: Thu Nov 01, 2018 2:04 am

Re: Using metabolics probe with DeGrooteFregly2016Muscle

Post by Iris Magnusdottir » Mon Aug 03, 2020 5:49 am

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!

User avatar
Nicholas Bianco
Posts: 963
Joined: Thu Oct 04, 2012 8:09 pm

Re: Using metabolics probe with DeGrooteFregly2016Muscle

Post by Nicholas Bianco » Mon Aug 03, 2020 9:57 am

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

User avatar
Ross Miller
Posts: 371
Joined: Tue Sep 22, 2009 2:02 pm

Re: Using metabolics probe with DeGrooteFregly2016Muscle

Post by Ross Miller » Wed Sep 02, 2020 8:05 am

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

User avatar
Nicholas Bianco
Posts: 963
Joined: Thu Oct 04, 2012 8:09 pm

Re: Using metabolics probe with DeGrooteFregly2016Muscle

Post by Nicholas Bianco » Wed Sep 02, 2020 11:40 am

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

User avatar
Ross Miller
Posts: 371
Joined: Tue Sep 22, 2009 2:02 pm

Re: Using metabolics probe with DeGrooteFregly2016Muscle

Post by Ross Miller » Wed Sep 02, 2020 2:07 pm

Thanks Nick, it looks like I already asked this question (I turn 40 next week, memory is going...)

User avatar
Nicholas Bianco
Posts: 963
Joined: Thu Oct 04, 2012 8:09 pm

Re: Using metabolics probe with DeGrooteFregly2016Muscle

Post by Nicholas Bianco » Fri Sep 04, 2020 3:12 pm

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.

User avatar
Karthick Ganesan
Posts: 118
Joined: Thu Oct 10, 2013 12:11 am

Re: Using metabolics probe with DeGrooteFregly2016Muscle

Post by Karthick Ganesan » Sat Sep 05, 2020 1:51 pm

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.

User avatar
Karthick Ganesan
Posts: 118
Joined: Thu Oct 10, 2013 12:11 am

Re: Using metabolics probe with DeGrooteFregly2016Muscle

Post by Karthick Ganesan » Sat Sep 05, 2020 1:59 pm

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.

POST REPLY