Page 1 of 1

MocoTrack doesn't work with a specific mesh interval

Posted: Tue Jul 02, 2024 4:47 pm
by kernalnet
Hi, my simple marker tracking simulation in OpenSim Moco works and converges successfully if I set the total number of meshes to 20, 25, 35, and 40. But I'm getting this error in case of 30 (or the mesh interval of 0.01):

CasADi - 2024-07-03 03:05:50 WARNING("nlp:nlp_jac_g failed: NaN detected for output jac_g_x, at nonzero index 67 (row 67, col 0).") [D:\a\opensim-core\opensim-core\dependencies\casadi\casadi\core\oracle_function.cpp:377]
Error evaluating Jacobian of equality constraints at user provided starting point.
No scaling factors for equality constraints computed!

Any idea why this is happening?
Thank you.

Re: MocoTrack doesn't work with a specific mesh interval

Posted: Fri Jul 05, 2024 9:49 am
by nbianco
Hi Mohammadreza,

Have you tried using the solution using 25 mesh intervals as the initial guess for the problem using 30? Usually this type of error has to do with the initial guess.

-Nick

Re: MocoTrack doesn't work with a specific mesh interval

Posted: Fri Jul 05, 2024 1:39 pm
by kernalnet
Hi Nick, thanks for your response. I will try this. Do you mean the problem is the initial guesses? Actually, I didn't specify any initial guess; everything was default. If I adjust the time range to be 0.005s greater or lower, the 0.01 mesh interval works without any issue. Here is a test case:
test.zip
(271.05 KiB) Downloaded 2 times
Thanks for your help,
-Mohammadreza

Re: MocoTrack doesn't work with a specific mesh interval

Posted: Fri Jul 05, 2024 2:07 pm
by nbianco
Moco always uses an initial guess. If you don't specify one, it will create a guess using the midpoint between the variable bounds. Possibly this default guess is a problem when using 30 mesh intervals for your problem.

When using different mesh intervals, the problem is discretized differently, meaning reference data in tracking goals will be sampled at different points in the trajectory. It could be that using 30 mesh intervals leads to a sample point in the reference data that is problematic.

Re: MocoTrack doesn't work with a specific mesh interval

Posted: Fri Jul 05, 2024 2:14 pm
by kernalnet
I appreciate your help. -Mohammadreza