Extracting force analysis with manager tool in Matlab
Posted: Fri Mar 03, 2023 10:58 am
Hello,
I'm trying to run a simulation and I'm using Manager tool with MATLAB API. Simulation runs perfectly and I can get the states.sto file and investigate/visualize it but I can't seem to find the functions to print out the forces (or any type of analysis that you could add while running Forward dynamic within the GUI). I'm just not sure how to extract the forces after I ran the simulation...
It would be amazing if someone could help me with this or to reference a code/file... I attached the portion of the code that runs the simulation in my code
import org.opensim.modeling.*
modelPath='D:\...
model = Model(modelPath);
%adding Reporters
forcerep = ForceReporter(model);
model.addAnalysis(forcerep);
%Running Simulation
state = model.initSystem();
manager = Manager(model);
manager.setPerformAnalyses(true);
state.setTime(0);
manager.initialize(state);
state = manager.integrate(0.5);
sTable = manager.getStatesTable();
stofiles = STOFileAdapter();
if ~isdir('ResultsFWD')
mkdir ResultsFWD
end
stofiles.write(sTable, 'ResultsFWD/simulation_states.sto');
display('Simulation Finished.');
I'm trying to run a simulation and I'm using Manager tool with MATLAB API. Simulation runs perfectly and I can get the states.sto file and investigate/visualize it but I can't seem to find the functions to print out the forces (or any type of analysis that you could add while running Forward dynamic within the GUI). I'm just not sure how to extract the forces after I ran the simulation...
It would be amazing if someone could help me with this or to reference a code/file... I attached the portion of the code that runs the simulation in my code
import org.opensim.modeling.*
modelPath='D:\...
model = Model(modelPath);
%adding Reporters
forcerep = ForceReporter(model);
model.addAnalysis(forcerep);
%Running Simulation
state = model.initSystem();
manager = Manager(model);
manager.setPerformAnalyses(true);
state.setTime(0);
manager.initialize(state);
state = manager.integrate(0.5);
sTable = manager.getStatesTable();
stofiles = STOFileAdapter();
if ~isdir('ResultsFWD')
mkdir ResultsFWD
end
stofiles.write(sTable, 'ResultsFWD/simulation_states.sto');
display('Simulation Finished.');