Run IK Tool in Matlab
Posted: Mon Aug 31, 2020 11:46 am
Hello,
I am trying to run the IK Tool by scripting with Matlab. Currently, I am getting the error that "InverseKinematicsTool Failed: Object: Cannot open file Unassigned. It may not exist or you do not have permission to read it."
I thought it might be because I didn't have the full file path assigned for the trc file, but I now do and I get the same error.
When I open the GUI and load the model specified in this script and run the IK tool using the setup file that is generated in this script, the simulation runs as anticipated and no warnings or errors appear in the GUI message window. This leads me to believe the file being written is correct.
Does anybody have any ideas why this script is throwing this error?
Thanks for your help,
EAD
I am trying to run the IK Tool by scripting with Matlab. Currently, I am getting the error that "InverseKinematicsTool Failed: Object: Cannot open file Unassigned. It may not exist or you do not have permission to read it."
I thought it might be because I didn't have the full file path assigned for the trc file, but I now do and I get the same error.
When I open the GUI and load the model specified in this script and run the IK tool using the setup file that is generated in this script, the simulation runs as anticipated and no warnings or errors appear in the GUI message window. This leads me to believe the file being written is correct.
Does anybody have any ideas why this script is throwing this error?
Code: Select all
%% Import OpenSim Libraries
import org.opensim.modeling.*;
% find geometry
ModelVisualizer.addDirToGeometrySearchPaths('I:\17_BuildOttobockWalkerModel\01_FirstPassSTLs')
ModelVisualizer.addDirToGeometrySearchPaths('C:\OpenSim 4.1\Geometry');
%% Load
model = Model('Norm09_scaled_wWalker.osim'); % load scaled model of Norm09 of human with walker
model.initSystem(); % start model
currentfolder = pwd;
markerFile = 'UVA10.trc';
trialname = regexprep(markerFile,'.trc',''); % replace the expression .trc with nothing in the markerFile string
fullMarkerFile = [currentfolder,'\',markerFile];
%% when to start and stop
% capture a little before to a little after one left gait cycle
initial_time = 1.5; % in sec
final_time = 3; % in sec
%% set up the IK tool
ikTool = InverseKinematicsTool('Setup_IK_noJCmarks.xml'); % load generic IK tool based off file that has markers enabled and weighted
ikTool.setName(trialname); % set to trial name
ikTool.setMarkerDataFileName(fullMarkerFile); % set trc to read
ikTool.setStartTime(initial_time); % when to start
ikTool.setEndTime(final_time); % when to stop
ikTool.setOutputMotionFileName([trialname,'_IKrez.mot']); % generate file in current folder to store IK results
% save settings file
ikTool.print(['Setup_IK_',trialname,'.xml']); % generates set-up xml in current folder
%% Run Inverse Kinematics
ikTool.run();
EAD