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
CMC tool on matlab ?
- Thomas Uchida
- Posts: 1793
- Joined: Wed May 16, 2012 11:40 am
Re: CMC tool 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).I would like to know if the CMCtool class and its methods (API) are usable on Matlab ?
- Mehran Elyasi
- Posts: 12
- Joined: Thu Jan 11, 2018 2:21 am
Re: CMC tool on matlab ?
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
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
- Thomas Uchida
- Posts: 1793
- Joined: Wed May 16, 2012 11:40 am
Re: CMC tool on matlab ?
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.
- Mehran Elyasi
- Posts: 12
- Joined: Thu Jan 11, 2018 2:21 am
Re: CMC tool on matlab ?
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,
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,
- Thomas Uchida
- Posts: 1793
- Joined: Wed May 16, 2012 11:40 am
Re: CMC tool on matlab ?
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
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.
Code: Select all
cmctool.print('CMC_setup.xml');
- Mehran Elyasi
- Posts: 12
- Joined: Thu Jan 11, 2018 2:21 am
Re: CMC tool on matlab ?
Thanks a lot for your input Tom,