Page 1 of 1

Set .mot file of External load applied during CMC

Posted: Thu Aug 16, 2018 6:07 pm
by tomaugenstein
I have a generic .xml external load file that I wish to use on several different iterations of CMC. For each iteration, I want to start a new CMCTool(setup), included in the setup file is the .xml external load file. I then want to pick a specific externalForce.mot file for the given trial. I have the following code but it is not working. Any tips?

model = Model([path 'scaled_upper_arm_CMC.osim']);
state = model.initSystem();
cmc = CMCTool(setup);

% Set-up trial specific output
exLoads = cmc.getExternalLoads.setDataFileName(motFile);
cmc.updExternalLoads();

% run CMC tool
cmc.run()

Re: Set .mot file of External load applied during CMC

Posted: Fri Aug 17, 2018 12:20 pm
by tkuchida
This line does nothing:

Code: Select all

cmc.updExternalLoads();
Methods with the "upd" prefix just return a writable reference, so all you're doing here is fetching the reference and throwing it away. Perhaps try the following:

Code: Select all

% Replace these lines...
exLoads = cmc.getExternalLoads.setDataFileName(motFile);
cmc.updExternalLoads();
% ...with this line
cmc.setExternalLoadsFileName(motFile);
You can print the CMCTool before running and open the file in a text editor to ensure your script has made the expected change.