Matlab version of example2DWalking

OpenSim Moco is a software toolkit to solve optimal control problems with musculoskeletal models defined in OpenSim using the direct collocation method.
User avatar
Aaron Fox
Posts: 275
Joined: Sun Aug 06, 2017 10:54 pm

Re: Matlab version of example2DWalking

Post by Aaron Fox » Mon Jan 20, 2020 7:59 pm

Just a follow up question for you Brian - what was your specific process/changes to the code for running the progressively faster simulations? I've been finding that the solver struggles and gives me some strange movement outputs with faster speeds. I may be trying to increase the speed too much in one go compared to your progressive simulations though.

It sounds like you altered the desired speed within the speed goal and relaxed the bounds on joint coordinates - but where there any other edits you made to generate appropriate faster gait solutions. For one example - did you have to open up the final time bounds to allow for a shorter duration solution to be reached? And were there any other parameters I'm missing that required a change?

Thanks,

Aaron

User avatar
Brian Umberger
Posts: 48
Joined: Tue Aug 28, 2007 2:03 pm

Re: Matlab version of example2DWalking

Post by Brian Umberger » Sun Jan 26, 2020 1:36 pm

Hi Aaron,

I'll preface this response by noting that varying the target speed was something I only played around with when I was starting out with Moco and did not investigate thoroughly or try to fine tune.

In addition to widening the bounds on the states I did also widen the bounds on the final time, allowing shorter step times. I set the lower bound to 0.05 s, ensuring it should not be reached. I also used more mesh intervals (75) and a looser convergence tolerance (1e-2) than what is in the walking example. I don't think I changed anything else.

Starting from the 1.2 m/s walking solution I solved problems with the speed goal set to 2.0, 2.5, 3.0, 3.5, 4.0 m/s, with the initial guess always being the solution from the next lower speed. The only one that had some trouble converging was 4.0 m/s. The gaits were not perfect, and tended to have shorter step lengths and higher step frequencies than what would be expected. At 3.0 m/s and above it was definitely running, with a clear flight phase. It's worth noting that I don't think Antoine used this 2-D model for running in his recent papers and it might not be well suited for simulating running (I'm not sure). The cost function he used was also more complex than this minimum control effort objective.

Best,
Brian

User avatar
Aaron Fox
Posts: 275
Joined: Sun Aug 06, 2017 10:54 pm

Re: Matlab version of example2DWalking

Post by Aaron Fox » Mon Jan 27, 2020 10:31 pm

Great - thanks for the info Brian.

I'd suggest that the looser convergence tolerance was important in these examples, as I had some difficulty getting the solutions to converge without doing this. I'm also trialling a more complex model with some existing running data as the initial guesses and hoping this may solve some of those oddities you saw in the running technique.

Aaron

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

Re: Matlab version of example2DWalking

Post by Karthick Ganesan » Tue Feb 11, 2020 11:27 am

Dear Prof. Brian Umberger,
I thank you very much for sharing the code. It is working. However it seems to work only while ignoring passive fiber force and active force length factor set to 1.5 (I have not tried the effect of these two options individually, used both these options simultaneously). How these options affect convergence?
The results of predictive simulation with coarse mesh and coarse tolerance , finer mesh and finer tolerance seems to be qualitatively similar. Could you please explain why did you use fine mesh and tolerance?
Predictive simulation with the same solver settings as tracking simulation in your code (100 mesh intervals and tolerance of 1e-5) took almost 3600 iterations and 18 hours in my computer. Even with 50 mesh intervals and 1e-4 tol took around 1800 iterations to converge. Did your simulation take these many number of iterations? Is it possible to improve the rate of convergence?
I will highly appreciate if you could please answer these questions.
Thanks & Regards,
Karthick.

User avatar
Brian Umberger
Posts: 48
Joined: Tue Aug 28, 2007 2:03 pm

Re: Matlab version of example2DWalking

Post by Brian Umberger » Mon Feb 24, 2020 10:16 am

Hello Karthick,

Thanks for your patience. I became busy with work and was not checking the forum.

For the example, I used a finer mesh and tighter tolerance because in the initial solutions I obtained there were oscillations in the GRFs, which appeared to be due to oscillation in the tendon forces for some of the muscles. Using a finer mesh and tighter tolerance substantially reduced the oscillations. I only ran a couple of predictive simulations of this case, and it did require similar numbers of iterations as you indicated.

I do not intend to use this particular model to do anything other than learn how to use Moco, so I have not spent any time trying to figure out why convergence is slower than expected, why there were oscillations in the muscle forces, the effects of including passive fiber force, etc. One possibility is some of the muscle parameters in this model might need to be adjusted. The questions you are asking are all relevant and appropriate, I just don't have any direct insights for this particular case.

Best regards,

Brian

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

Re: Matlab version of example2DWalking

Post by Karthick Ganesan » Thu Feb 27, 2020 7:32 am

Dear Prof. Brian Umberger,
Thanks for your answers and suggestions. I will explore more on these issues.

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

Re: Matlab version of example2DWalking

Post by Karthick Ganesan » Thu Feb 27, 2020 7:36 am

Hi Moco Team,
Do you have any suggestions for these questions?
Thanks,
Karthick.

User avatar
Brian Umberger
Posts: 48
Joined: Tue Aug 28, 2007 2:03 pm

Re: Matlab version of example2DWalking

Post by Brian Umberger » Thu Mar 05, 2020 5:43 pm

Hi Karthick,

Here is a potential solution that arose in trying to address a similar issue with my own model.

After you create the model object, set the tendon compliance dynamics mode to "implicit"

Code: Select all

modelProcessor.append(ModOpTendonComplianceDynamicsModeDGF('implicit'));
You can then comment out the lines for IgnorePassiveFiberForces and ScaleActiveFiberForceCurveWidth.

Next, when you configure the solver, set it to minimize the auxiliary derivatives (tendon force derivatives, in this case) with a weight of around 0.1 (that worked, but I did not try to fine-tune this weight).

Code: Select all

solver.set_minimize_implicit_auxiliary_derivatives(true);
solver.set_implicit_auxiliary_derivatives_weight(0.1);
These changes largely suppress the oscillations in the tendon forces, and permit good convergence for tracking and predictive simulations (250-350 iterations) using a reasonable mesh intervals (50) and tolerances (1e-3). I hope this helps.

Brian

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

Re: Matlab version of example2DWalking

Post by Karthick Ganesan » Fri Mar 06, 2020 1:46 am

Dear Prof. Brian Umberger,
Thank you very much for sharing your experience.
Recently I also tried the implicit mode for a tracking simulation and it almost halved the number of iterations.I did not try out other options though.

Thanks a lot,
Karthick.

User avatar
Aaron Fox
Posts: 275
Joined: Sun Aug 06, 2017 10:54 pm

Re: Matlab version of example2DWalking

Post by Aaron Fox » Thu Mar 12, 2020 9:20 pm

Hi Karthick,

Presumable with half the number of iterations the solver worked much faster?

Perhaps Nick, Chris and/or Brian could provide some background on what the explicit vs. implicit mode does and what the pros/cons of each are?

Thanks,

Aaron

POST REPLY