Adding Force Set for Static optimization in Matlab

Provide easy-to-use, extensible software for modeling, simulating, controlling, and analyzing the neuromusculoskeletal system.
POST REPLY
User avatar
Bryan Schlink
Posts: 2
Joined: Fri Sep 15, 2017 8:19 am

Adding Force Set for Static optimization in Matlab

Post by Bryan Schlink » Thu Nov 30, 2017 9:59 am

Hi all,

I am attempting to run a static optimization using Matlab, but I'm having trouble trying to get the program to use the force set file. In the GUI, I would append additional force set files under the actuator tab. And the coding for this is in the xml file I use to set the settings of the analyze tool. The method in AnalyzeTool that I think I should use is "setForceSetFiles", but the class for this is "org.opensim.modelling.ArrayStr" and "SOTool.setForceSetFiles(ArrayStr([dirorig '\CMC_Actuators_rai.xml']));" doesn't work. (SOTool is the name of the AnalyzeTool).

Any help or advice would be appreciated. Without appending the force set, I can't solve the optimization.

Thank-you!

User avatar
jimmy d
Posts: 1375
Joined: Thu Oct 04, 2007 11:51 pm

Re: Adding Force Set for Static optimization in Matlab

Post by jimmy d » Thu Nov 30, 2017 11:32 am

You have to build the ArrayStr() before you can set its value and use it. The below code works for me in Matlab.

Code: Select all

% Construct an AnalyzeTool from an existing file
at = AnalyzeTool('so_setup.xml');
% Instantiate a String Array
as = ArrayStr();
% Set the first value of the array to the actuators file
as.set(0,'gait2354_RRA_Actuators.xml')
% Set the force set file to use the new array
at.setForceSetFiles(as)

User avatar
Bryan Schlink
Posts: 2
Joined: Fri Sep 15, 2017 8:19 am

Re: Adding Force Set for Static optimization in Matlab

Post by Bryan Schlink » Thu Nov 30, 2017 3:52 pm

Thank you for the help. Unfortunately I'm still having issues. I don't believe it is because of the force set anymore (I have a "Adding force object set from CMC_Actuators_rai.xml" message pop up when I initialize the model). But optimization still fails and constraint violations are really high. The data follows the same path as the data I found using the GUI, but it's very noisy. Is there a common mistake made when setting up static optimization in matlab that leads to really poor results?

I can post my entire code if that would help.

Thanks again.

POST REPLY