Predict walking pattern by using OpenSim-Moco

OpenSim Moco is a software toolkit to solve optimal control problems with musculoskeletal models defined in OpenSim using the direct collocation method.
User avatar
Burak Kula
Posts: 31
Joined: Wed Dec 04, 2019 3:34 pm

Predict walking pattern by using OpenSim-Moco

Post by Burak Kula » Wed Aug 05, 2020 2:50 am

Dear OpenSim Users,

I am a master student at Bogazici University/Istanbul. For my master thesis, I will use Moco to predict gait pattern of pathological patients. I have tried example files in Moco but it was challenging for me to adjust those MATLAB codes for my walking pattern.

It would be quite nice, if you share with me some of example working materials which include MATLAB code regarding walking trials, in order to be a guidance for a starting point for me.

I would be appreciated your help.

All the best,
Burak KULA - Bogazici University.

User avatar
Carlos Gonçalves
Posts: 127
Joined: Wed Jun 08, 2016 4:56 am

Re: Predict walking pattern by using OpenSim-Moco

Post by Carlos Gonçalves » Fri Aug 14, 2020 8:01 am

Hello Burak,

Have you checked the example code provided by Ross Miller?
https://opensim-org.github.io/opensim-moco-site/blog/

It is very well documented and uses MATLAB.

I need to work with Python but I'm using it to study OpenSim Moco.

Hope it helps.

Best regards.

User avatar
Burak Kula
Posts: 31
Joined: Wed Dec 04, 2019 3:34 pm

Re: Predict walking pattern by using OpenSim-Moco

Post by Burak Kula » Mon Aug 17, 2020 1:32 am

Hello Carlos,

Thank you for your help and guidance. I tried to run Miller's code without any modifications and I had an error given bellow.
Do you have any idea about this error ? How can I solve it?
Capture.PNG
Capture.PNG (17.35 KiB) Viewed 871 times
I would like to thank you again.
Best regards,

User avatar
Carlos Gonçalves
Posts: 127
Joined: Wed Jun 08, 2016 4:56 am

Re: Predict walking pattern by using OpenSim-Moco

Post by Carlos Gonçalves » Mon Aug 17, 2020 11:48 am

Hello Burak,

I haven't gone through all the steps in the MATLAB file yet. I don't work with MATLAB.

From the error message, the solver couldn't solve the problem. It even used all its iterations.

To get something working right away, there is also the "squat-to-stand" MATLAB tutorial https://simtk-confluence.stanford.edu/d ... t-to-stand

I'm currently working on the 2D_gait example. It worked in Python after a week of code learning/rewriting.

Hope you can solve the issue.

Best regards.

User avatar
Christopher Dembia
Posts: 506
Joined: Fri Oct 12, 2012 4:09 pm

Re: Predict walking pattern by using OpenSim-Moco

Post by Christopher Dembia » Mon Aug 17, 2020 11:52 am

Carlos,

It's great to hear you got example2DWalking working in Python. Also, thank you for helping out on the forum. Would you be interested in contributing this back to the project? No pressure.

-Chris

User avatar
Carlos Gonçalves
Posts: 127
Joined: Wed Jun 08, 2016 4:56 am

Re: Predict walking pattern by using OpenSim-Moco

Post by Carlos Gonçalves » Tue Aug 18, 2020 7:37 am

Hello Chris!

Sure, it will be a pleasure to contribute. It is not the best python code (smallest line number) but it does the deal. I'm currently tweaking it (slowly) to get it working as you, Falisse and others did in https://royalsocietypublishing.org/doi/ ... .2019.0402.

I never did a git pull before but I will try it soon. Or maybe I could just send a dropbox link :lol:

It is a pleasure to help. One minute helping someone is maybe some hours saved for science.

By the way, OpenSim Moco is AMAZING! Congratulations to the team!

Best regards.

User avatar
Carlos Gonçalves
Posts: 127
Joined: Wed Jun 08, 2016 4:56 am

Re: Predict walking pattern by using OpenSim-Moco

Post by Carlos Gonçalves » Tue Aug 18, 2020 12:13 pm

04kulaburak wrote:
Mon Aug 17, 2020 1:32 am
Hello Carlos,

Thank you for your help and guidance. I tried to run Miller's code without any modifications and I had an error given bellow.
Do you have any idea about this error ? How can I solve it?

Capture.PNG

I would like to thank you again.
Best regards,
Just found the same error with my simulation. It simply couldn't converge.

use:

solution = study.solve()
solution.unseal()

And it will at least show some solution. Might help you.

Best regards.

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

Re: Predict walking pattern by using OpenSim-Moco

Post by Nicholas Bianco » Tue Aug 18, 2020 1:31 pm

Hi Carlos and Burak,

Could you provide more information on the solution after calling unseal()? The problem should run out of the box; it would be good to figure out what's going wrong since both of you don't see convergence.

-Nick

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

Re: Predict walking pattern by using OpenSim-Moco

Post by Ross Miller » Tue Aug 18, 2020 4:57 pm

Hi Burak,

As others noted, that error/warning is because Moco ceased the optimization without converging, so it "sealed" the solution at the final iteration. I assume this is so users don't accidentally miss the fact that the optimizer didn't converge.

If the optimizer exited because it exceeded the max number of iterations, you can try increasing that, or decreasing the convergence tolerances. 17 minutes is a pretty short CPU time especially if you are using the 3-D model.

The codes I uploaded should converge on a solution when run as-provided (at least, they do that on my machine) but I haven't rigorously tested them. There are some elements of them that aren't great for convergence, e.g. the arms are controlled by torque generators that don't have to have smooth torques. I keep meaning to upload some updates.

Ross

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

Re: Predict walking pattern by using OpenSim-Moco

Post by Karthick Ganesan » Wed Aug 19, 2020 1:45 am

Hi all,
The optimization did converge when it was run as it is. I tried it long back. I think it took quite a few hours to converge in my machine.
Regards,
Karthick.

POST REPLY