Page 1 of 1

Forward Tool results not consistent

Posted: Thu Feb 02, 2023 12:27 pm
by andrewklapre
Hi everyone,

I'm having an issue where the results in the first second of simulation change significantly between simulations with the Forward Tool in OpenSim 4.4. The model is relatively simple, modified Gait2354 with no actuator controls, and the joints have coordinate limit forces (I've simplified the model to troubleshoot this problem). I'm using the FT to just let it fall freely with an initial pelvis ty velocity of -6m/s, and the results only make sense once in a while. Most of the time, the hips rotate excessively past the limit. Once in a while the results make sense and the hips barely rotate, which is expected with no external forces applied to them and coordinate limit forces applied. If I click simulate (green button) the results are as expected every time. I discovered this through the API, then thinking I was scripting something incorrectly switched to the GUI and got the same results.

What is the difference between the green "Simulate" button and Forward Dynamics tool? Any idea why I might get inconsistent and incorrect results with the Forward Tool? Should I switch to OpenSim 4.3?

Thanks in advance.

Re: Forward Tool results not consistent

Posted: Thu Feb 02, 2023 1:37 pm
by andrewklapre
One thing I just noticed, is if I run the Forward Tool first, the results are wrong. If I then click simulate with the same initial conditions, the results make sense. THEN if I run the Forward Tool, the results are correct and match the "Simulate" results.

The problem is that I want to crank through a ton of parameters through the API and can't use the GUI for that. Is there a class "Simulate" in the API rather than using the Forward Tool through the API? I would think that they are the same but "Simulate" in the GUI does something that the Forward tool doesn't, leading to the correct results.

Re: Forward Tool results not consistent

Posted: Thu Feb 02, 2023 1:48 pm
by aymanh
Hi Andrew,

The run button in OpenSim GUI does indeed call the forward tool with some built in assumptions, so there should be no difference if the settings are the same. When you run the forward tool using the dialog you have much more flexibility in setting options/analyses etc. The code behind the run/simulate button is here
https://github.com/opensim-org/opensim- ... n.java#L57

The likely difference you're seeing is due to the

Code: Select all

setSolveForEquilibrium(true)
call. If you check the box and set the initial and final time the same in the dialog and do nothing else then run you should get the same results, and you can reproduce the same using matlab or python API calls to do batch processing.

Please let us know if that works for you,
-Ayman

Re: Forward Tool results not consistent

Posted: Thu Feb 02, 2023 1:57 pm
by andrewklapre
Hi Ayman,

This indeed solved the problem, both in the GUI and API. However, I think there might be a bug. Once I set "solve for equilibrium" to true in the GUI and run once, subsequent runs with the Forward Tool with the option set to false have the correct results.

Anyways, I'm glad you were able to help me. Thank you!