OpenSim Moco is a software toolkit to solve optimal control problems with musculoskeletal models defined in OpenSim using the direct collocation method.
-
Nicholas Bianco
- Posts: 1041
- Joined: Thu Oct 04, 2012 8:09 pm
Post
by Nicholas Bianco » Wed Oct 26, 2022 9:41 am
Hi Carlos,
What you're looking for is
MocoFinalOutputGoal.
CoM velocity would need a custom goal I think. Since it is not a state of the model, I don't think it could be used in MocoOutputGoal, but you could try something like pelvis vertical velocity with MocoOutputGoal.
Not true! You can use MocoOutputGoal (and all the new related goals) with any model
Output, which does not have to be a state of the system. You can find a
list of the Outputs a component supports on the Doxygen documentation page for that component.
So, you can maximize the final center of mass height using MocoFinalOutputGoal with a negative weight.
-Nick
-
Carlos Gonçalves
- Posts: 135
- Joined: Wed Jun 08, 2016 4:56 am
Post
by Carlos Gonçalves » Wed Oct 26, 2022 1:17 pm
Perfect! Thanks a lot Nick!!!!
So, if I want to use the pelvis_ty value, I just use the output from bodyset/pelvis|position right into MocoOutputFinalGoal? The negative weight was something that I just thought another day about why I never used...
But for the CoM, how can it be done? I see the documentation on calcMassCenterPosition but does it "fit" into MocoOutputFinalGoal? What are the available options?
Maybe model|com_position ? I previous set something like this in my rowing model like this:
Code: Select all
tensionGoal = osim.MocoOutputGoal('tension', listParam[parmDict['tensionWeight']])
tensionGoal.setOutputPath('/forceset/forcaRemoErgometro|tension')
tensionGoal.setDivideByDisplacement(True)
tensionGoal.setDivideByMass(True)
problem.addGoal(tensionGoal)
I couldn't find an example in
https://opensim-org.github.io/opensim-moco-site/docs/
Best regards.
Carlos
-
Nicholas Bianco
- Posts: 1041
- Joined: Thu Oct 04, 2012 8:09 pm
Post
by Nicholas Bianco » Wed Oct 26, 2022 1:58 pm
Ah dang, the link to the Moco docs on the website is out of date. I'll fix that soon!
Either way, I don't think there's an example for model-level Outputs anywhere. Model components are listed using a file directory format, but the model itself has no "directory". So it would look like this in a MocoOutputGoal:
Code: Select all
maxHeightGoal = osim.MocoFinalOutputGoal('max_com_height')
maxHeightGoal.setOutputPath('|com_position')
maxHeightGoal.setWeight(-1.0) # maximize height
maxHeightGoal.setOutputIndex(1) # the y-axis index
maxHeightGoal.setExponent(1) # keep height signed (1 is the default value)
Center of mass position is a Vec3 type, so you need to select the direction using setOutputIndex(). The weight and setExponent() will make sure you specifically maximize height.
Best,
Nick
-
Ross Miller
- Posts: 375
- Joined: Tue Sep 22, 2009 2:02 pm
Post
by Ross Miller » Thu Oct 27, 2022 4:16 am
Thanks Nick!
Could use this same/similar approach to maximize CoM horizontal velocity (sprinting)? I guess I would want MocoOutputGoal for that (maximize average velocity).
Ross
-
Nicholas Bianco
- Posts: 1041
- Joined: Thu Oct 04, 2012 8:09 pm
Post
by Nicholas Bianco » Thu Oct 27, 2022 5:20 pm
Ross -- I think you could. I tried to include as many options as possible to make these goals as flexible as possible.
-
Carlos Gonçalves
- Posts: 135
- Joined: Wed Jun 08, 2016 4:56 am
Post
by Carlos Gonçalves » Thu Oct 27, 2022 5:58 pm
Thanks a lot Nick!!
Really appreciate the example code. I will use in the future with 92 muscles (double fingers crossed).
And here are the results! A lot of improvements. Thanks a lot Tom, Ross and Nick!
Both simulations took more than 10h. So I couldn't test all the scenarios discussed here, but definitely, just setting the final speed bound of pelvis_ty to zero did the trick. 100% stronger, 37.5% higher jump. On the left reference, on the right stronger model.
https://www.youtube.com/watch?v=MOEch5B ... C3%A7alves
- compare.png (163.06 KiB) Viewed 876 times
I still didn't get all the muscles to "bang-bang", but I will keep digging into this.
Thanks again for all the support. Best regards.
Carlos
-
Ross Miller
- Posts: 375
- Joined: Tue Sep 22, 2009 2:02 pm
Post
by Ross Miller » Sat Oct 29, 2022 6:07 am
Looks good!
I think one of the earliest jumping simulations with a complex model (Pandy et al. 1990) has an argument on why the optimal controls must be bang-on. I'm not sure if that would extend to a cost function with an effort term though. They were just maximizing take-off velocity (or more specifically, take-off height + velocity^2 / 2g).
Ross
-
Carlos Gonçalves
- Posts: 135
- Joined: Wed Jun 08, 2016 4:56 am
Post
by Carlos Gonçalves » Mon Oct 31, 2022 6:09 pm
Thanks Ross.
Mr. Bones is getting wiser with the help from the forum.
I will continue exploring the weights for the goals, as well as comparing them to the literature. The main goal is to use this problem (jumping) to fine-tune the procedures for further clinical motions.
I just thought that looking into published research on EMG for jumping (areal phase) could guide in the selection or not of the MocoControlGoal in the future.
Best regards.