Forward Tool results not consistent

Provide easy-to-use, extensible software for modeling, simulating, controlling, and analyzing the neuromusculoskeletal system.
POST REPLY
User avatar
Andrew LaPre
Posts: 8
Joined: Wed Jun 01, 2022 1:19 pm

Forward Tool results not consistent

Post by Andrew LaPre » Thu Feb 02, 2023 12:27 pm

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.

Tags:

User avatar
Andrew LaPre
Posts: 8
Joined: Wed Jun 01, 2022 1:19 pm

Re: Forward Tool results not consistent

Post by Andrew LaPre » Thu Feb 02, 2023 1:37 pm

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.

User avatar
Ayman Habib
Posts: 2238
Joined: Fri Apr 01, 2005 12:24 pm

Re: Forward Tool results not consistent

Post by Ayman Habib » Thu Feb 02, 2023 1:48 pm

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

User avatar
Andrew LaPre
Posts: 8
Joined: Wed Jun 01, 2022 1:19 pm

Re: Forward Tool results not consistent

Post by Andrew LaPre » Thu Feb 02, 2023 1:57 pm

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!

POST REPLY