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
Nicholas Bianco
Posts: 963
Joined: Thu Oct 04, 2012 8:09 pm

Re: Using metabolics probe with DeGrooteFregly2016Muscle

Post by Nicholas Bianco » Thu Sep 10, 2020 1:08 pm

The Muscle class has an Output for the active force-length multiplier (called 'active_force_length_multiplier'). So you can compute it with analyze() just like any other Output.

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

Re: Using metabolics probe with DeGrooteFregly2016Muscle

Post by Karthick Ganesan » Wed Sep 23, 2020 8:13 am

I'm not sure what you mean. The output in MocoOutputGoal is included in the integrated cost function.
I mean, for example, is it possible to square the fiber power and then minimize it using MocoOutputGoal?
Thanks.

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 23, 2020 11:20 am

Ah yes, the output value is included in the integrand without any modifications. You cannot change the power on the output value currently.

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

Re: Using metabolics probe with DeGrooteFregly2016Muscle

Post by Ross Miller » Thu Mar 04, 2021 10:13 am

Hi all,

Bumping this thread to ask a question about study.analyze:

Is there a way to use study.analyze to compute and report the joint reaction force(s) in a specified reference frame? Essentially I would like to calculate the output for MocoJointReactionGoal, e.g. knee compressive force (https://opensim-org.github.io/opensim-moco-site/docs/), but want to do it from a specified MocoTrajectory so that I can look at the time series of the knee compressive force.

Something like:

Code: Select all

outputPaths = StdVectorString();
outputPaths.add('path_to_this_output');
outputTable = study.analyze(soln, outputPaths);
Ross

User avatar
Pasha van Bijlert
Posts: 214
Joined: Sun May 10, 2020 3:15 am

Re: Using metabolics probe with DeGrooteFregly2016Muscle

Post by Pasha van Bijlert » Mon Mar 08, 2021 12:50 pm

Hi Ross,

I think we're after the same goal (getting a time series of any given joint reaction force/moment from a MocoTrajectory). I tried the following:

Code: Select all

 
 JR_paths=StdVectorString();
 JR_paths.add('.*reaction_on_parent');
 JR_paths.add('.*reaction_on_child');
 
 
JR_outputs_table=study.analyze(mocoTrajectory, JR_paths);
JR_outputs=osimTableToStruct(JR_outputs_table);
This doesn't work, because the output of a joint reaction force/moment is of the type "SpacialVec", and the analyze tool ignores those outputs. Did you happen to find a way around this?

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

Re: Using metabolics probe with DeGrooteFregly2016Muscle

Post by Ross Miller » Mon Mar 08, 2021 2:39 pm

I have not. In reading over some posts on the main OpenSim forum it looks like the Analyze tool does not support SpatialVec so I think this would have to be addressed in a future version of OpenSim (outside the scope of Moco).

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 » Mon Mar 08, 2021 2:49 pm

Hey guys,

In Matlab, you should be able to use analyzeSpatialVec() for calculating joint reaction forces like you would use analyze() to calculate scalar quantities.

User avatar
Kayla Pariser
Posts: 15
Joined: Mon Jul 30, 2018 10:35 am

Re: Using metabolics probe with DeGrooteFregly2016Muscle

Post by Kayla Pariser » Wed Jan 18, 2023 9:50 am

Hi,
I was wondering if either of you had figured out this problem? I am now trying to output joint moments from a Moco Trajectory and analyzeSpatialVec() doesn't appear to be an existing function. Is there another function I can use? Thank you for your help.

Kayla

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 Jan 18, 2023 2:58 pm

Hi Kayla,

How are you calling analyzeSpatialVec()? To clarify, it is not a function on MocoStudy, but rather a utility function under SimulationUtilities. That means you should call using the 'opensimSimulation' prefix in Matlab:

Code: Select all

outputPaths = StdVectorString();
outputPaths.add('/path/to/output');
table = opensimSimulation.analyzeSpatialVec(model, ...
    solution.exportToStatesTable(), ...
    solution.exportToControlsTable(), ...
    outputPaths);
Hope that helps!

-Nick

User avatar
Pasha van Bijlert
Posts: 214
Joined: Sun May 10, 2020 3:15 am

Re: Using metabolics probe with DeGrooteFregly2016Muscle

Post by Pasha van Bijlert » Sat Jan 28, 2023 10:52 am

Hi Kayla,

In addition to Nick's code suggestion, I've also posted a code implementation in this thread based on Nick working through this problem with me.
Maybe that helps?
Cheers,
Pasha

POST REPLY