CMC tool on matlab ?

Provide easy-to-use, extensible software for modeling, simulating, controlling, and analyzing the neuromusculoskeletal system.
POST REPLY
User avatar
Alper Ayaz
Posts: 6
Joined: Tue Jan 16, 2018 1:27 am

CMC tool on matlab ?

Post by Alper Ayaz » Mon Feb 19, 2018 2:40 am

Dear colleagues,

Currently in internship dealing with OpenSim and Matlab, I would like to know if the CMCtool class and its methods (API) are usable on Matlab ?

Thank you,

Alper

User avatar
Thomas Uchida
Posts: 1790
Joined: Wed May 16, 2012 11:40 am

Re: CMC tool on matlab ?

Post by Thomas Uchida » Mon Feb 19, 2018 11:30 am

I would like to know if the CMCtool class and its methods (API) are usable on Matlab ?
Yes, you should be able to configure CMCTool and then run it from MATLAB, though loading settings from a setup file might be easier. Please see the "Scripting with Matlab" page in the Confluence documentation (https://simtk-confluence.stanford.edu:8 ... ith+Matlab).

User avatar
Mehran Elyasi
Posts: 12
Joined: Thu Jan 11, 2018 2:21 am

Re: CMC tool on matlab ?

Post by Mehran Elyasi » Tue Feb 20, 2018 3:42 am

Hi Tom, could you please help me where my mistake is:


clc
clear all

import org.opensim.modeling.*
model = Model('subject01_metabolics_spring.osim');
cmctool = CMCTool();

%%%%%% Main Settings

cmctool.setModel(model);
cmctool.setDesiredKinematicsFileName('.\RRA\ResultsRRAsubject_adjusted_Kinematics_q.sto')
cmctool.setTaskSetFileName('gait10dof_Kinematics_Tracking_Tasks.xml');

cmctool.setStartTime(0.6);
cmctool.setFinalTime(1.9);
cmctool.setTimeWindow(0.01);


cmctool.setResultsDir('./Resultsout');
cmctool.setOutputPrecision(8);

%%%%%%% Actuators and External Loads

cmctool.setReplaceForceSet(false);
cmctool.setExternalLoadsFileName('.\ExperimentalData\subject01_walk_grf.mot');

%%%%%% something is missing here??

%%%%%%% Integrator Settings

cmctool.setMaximumNumberOfSteps(20000);
cmctool.setMaxDT(1);
cmctool.setMinDT(0.00000001);
cmctool.setErrorTolerance(0.00001);

cmctool.run();



=========> After run Matlab does not show an error message

but the run creates an "out.log" file that says:

Loaded model walk_subject01_ankle_spring from file subject01_metabolics_spring.osim
Running tool .
Error: failed to construct ExternalLoads from file .\ExperimentalData\subject01_walk_grf.mot. Please make sure the file exists and that it contains an ExternalLoadsobject or create a fresh one.

Exception:
Object: ERR- Could not open file .\ExperimentalData\subject01_walk_grf.mot.
It may not exist or you don't have permission to read it.
file= C:\OpenSim33\src\opensim32\OpenSim\Common\Object.cpp
line= 114

User avatar
Thomas Uchida
Posts: 1790
Joined: Wed May 16, 2012 11:40 am

Re: CMC tool on matlab ?

Post by Thomas Uchida » Tue Feb 20, 2018 11:39 am

It looks like the file ".\ExperimentalData\subject01_walk_grf.mot" cannot be found. I suggest replacing relative paths with absolute paths. If issues persist, you might want to set up your simulation using the GUI first (to take any MATLAB issues out of the equation), then write the corresponding MATLAB script and ensure your MATLAB results match the results generated using the GUI.

User avatar
Mehran Elyasi
Posts: 12
Joined: Thu Jan 11, 2018 2:21 am

Re: CMC tool on matlab ?

Post by Mehran Elyasi » Tue Feb 20, 2018 1:28 pm

thanks a lot Tom, for the "Actuators and External Loads" section in the CMC tool GUI in opensim,

what are the Matlab equivalent codes?

can you help me on this? do you have experience in this?

if you look at what I wrote apparently it is not enough,

User avatar
Thomas Uchida
Posts: 1790
Joined: Wed May 16, 2012 11:40 am

Re: CMC tool on matlab ?

Post by Thomas Uchida » Tue Feb 20, 2018 3:25 pm

I recommend specifying an absolute path rather than a relative path to rule out a path-related issue (I'm not sure what the working directory will be so I can't tell you where ".\ExperimentalData\subject01_walk_grf.mot" will be pointing). Beyond that, I recommend setting up the simulation using the GUI, saving the setup file, and then writing the MATLAB script such that

Code: Select all

cmctool.print('CMC_setup.xml');
produces the same setup file as you saved from the GUI. The doxygen documentation for CMCTool can be found here: https://simtk.org/api_docs/opensim/api_ ... CTool.html.

User avatar
Mehran Elyasi
Posts: 12
Joined: Thu Jan 11, 2018 2:21 am

Re: CMC tool on matlab ?

Post by Mehran Elyasi » Wed Feb 21, 2018 3:34 am

Thanks a lot for your input Tom,

POST REPLY