Different SO results from OpenSim 4.2 GUI and API

Provide easy-to-use, extensible software for modeling, simulating, controlling, and analyzing the neuromusculoskeletal system.
POST REPLY
User avatar
Rahid Zaman
Posts: 31
Joined: Fri Apr 21, 2017 3:43 am

Different SO results from OpenSim 4.2 GUI and API

Post by Rahid Zaman » Mon Jul 05, 2021 5:11 pm

Hello,
I was trying to run Static optimization in API. I also used same settings and files to run Static optimization in OpenSim 4.2 GUI. Although all the time points are not solved yet, I was expecting that the results would be same as both of them are the most up-to-date versions.
GUI results:
GUI_results.PNG
GUI_results.PNG (84.83 KiB) Viewed 443 times
API results:
API_results.PNG
API_results.PNG (104.37 KiB) Viewed 443 times
All the files can be found in this link: https://drive.google.com/file/d/1Ls5c23 ... sp=sharing

Can anybody help me to find out the reasons behind these differences?

Tags:

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

Re: Different SO results from OpenSim 4.2 GUI and API

Post by Ayman Habib » Tue Jul 06, 2021 8:50 am

Hi Rahid,

Both the GUI and API execute the same code so should lead to same results. The likely culprits are:
- External files (e.g. Actuators, reserves, external forces) that were resolved differently which could happen due to differences in working directory where you're running from. Check log messages/window for clues or to compare the two workflows.
- Differences in how the model is initialized. The GUI uses the current model/state from the live application while the API may use either a live model or a model loaded from a file (the model file gets ignored by the GUI since it operates on the current model).

Hope this helps,
-Ayman

User avatar
Rahid Zaman
Posts: 31
Joined: Fri Apr 21, 2017 3:43 am

Re: Different SO results from OpenSim 4.2 GUI and API

Post by Rahid Zaman » Thu Jul 08, 2021 8:54 am

Thank you, Dr. Ayman. The problem is solved. There were some dissimilarities between the static optimization setting files.
Another things is, in the GUI version, there is a "Message" window, where I can see at which time points the static optimization fails to solve. How can I do that in Matlab for OpenSim API? Any suggestions how I can know whether the static optimization is failing or not?

Thanks,
Rahid

User avatar
Mike Spahr
Posts: 14
Joined: Mon May 04, 2020 7:59 am

Re: Different SO results from OpenSim 4.2 GUI and API

Post by Mike Spahr » Mon Jul 26, 2021 5:50 am

Hello Rahid,

thanks for sharing your code it solved a similar problem with my Static Optimization code.
In my Matlab API it generates a opensim.log file in the folder, from which I run the first OpenSim matlab script. This log file is then used, even if you execute another matlab OpenSim script located elsewhere. (All logs are added at the end of the opensim.log file) Only when you restart your Matlab session, a new opensim.log can be generated if you choose another folder.

I hope this helps.

Best,
Mike

POST REPLY