Hi Tom,
Thanks for your help.
I am now trying to include a ForceReporter in the script. I can manually create an .mot file and load it in the OpenSim gui, add Analysis and save the Forces. However, when I try this in Matlab is doesn't work - I just get the header information, but no data.
I have tried loading the mot file
Forces = ForceReporter('mot filename')
Forces.printResults('ResultsDirectory')
I've looked at the Dyoxygen but I think I am missing a step where I actually run the analysis.
Niamh
CoordinateActuator and Constraint Violation
- Niamh Gill
- Posts: 11
- Joined: Wed Dec 03, 2014 5:37 am
- Thomas Uchida
- Posts: 1798
- Joined: Wed May 16, 2012 11:40 am
Re: CoordinateActuator and Constraint Violation
Hi Niamh,
The "CallForwardTool.m" function in the Dynamic Walking Challenge example (http://simtk-confluence.stanford.edu:80 ... Id=5113821) demonstrates adding a ForceReporter to a model, so I assume you have it wired up properly. Since you're integrating outside OpenSim, the method that appends rows to the ForceReporter isn't getting called. I think you should be able to append rows by calling this method yourself:
The doxygen documentation (https://simtk.org/api_docs/opensim/api_ ... orter.html) isn't too helpful, but the source code (https://github.com/opensim-org/opensim- ... r.cpp#L291) is commented. The second argument to the step() method is normally used to ensure the requisite number of steps have been taken before appending a new row (default is 1); see https://github.com/opensim-org/opensim- ... s.cpp#L234.
Regards,
Tom
The "CallForwardTool.m" function in the Dynamic Walking Challenge example (http://simtk-confluence.stanford.edu:80 ... Id=5113821) demonstrates adding a ForceReporter to a model, so I assume you have it wired up properly. Since you're integrating outside OpenSim, the method that appends rows to the ForceReporter isn't getting called. I think you should be able to append rows by calling this method yourself:
Code: Select all
% Create ForceReporter, add to Model, call initSystem(), etc.
...
% Before simulation
status = forceReporter.begin(osimState); %initializes the ForceReporter
if (status ~= 0), error('ForceReporter::begin() failed'); end
...
% During simulation
status = forceReporter.step(osimState, 1); %appends row (the "1" is explained below)
if (status ~= 0), error('ForceReporter::step() failed'); end
...
% After simulation
status = forceReporter.end(osimState); %appends row (should include a check to avoid
%duplicating the last row appended by step())
if (status ~= 0), error('ForceReporter::end() failed'); end
Regards,
Tom