Skip to content

Commit f6189e4

Browse files
Merge pull request #2881 from opensim-org/fix_ik_imus_for_gui_use
Fix ik imus for GUI use
2 parents 3103818 + 626484c commit f6189e4

File tree

4 files changed

+16
-9
lines changed

4 files changed

+16
-9
lines changed

Bindings/simulation.i

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,8 +222,8 @@ OpenSim::ModelComponentSet<OpenSim::Controller>;
222222
%shared_ptr(OpenSim::MarkersReference);
223223
%template(SetMarkerWeights) OpenSim::Set<MarkerWeight, OpenSim::Object>;
224224
%include <OpenSim/Simulation/CoordinateReference.h>
225-
%template (SetOientationWeights) OpenSim::Set<OrientationWeight, OpenSim::Object>;
226225
%include <OpenSim/Simulation/OrientationsReference.h>
226+
%template (SetOientationWeights) OpenSim::Set<OrientationWeight, OpenSim::Object>;
227227
%shared_ptr(OpenSim::OrientationsReference);
228228
%include <OpenSim/Simulation/BufferedOrientationsReference.h>
229229
%shared_ptr(OpenSim::BufferedOrientationsReference);

OpenSim/Tools/IMUInverseKinematicsTool.cpp

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,10 @@ void IMUInverseKinematicsTool::runInverseKinematicsWithOrientationsFromFile(
154154
model.setUseVisualizer(true);
155155
SimTK::State& s0 = model.initSystem();
156156

157+
AnalysisSet& analysisSet = model.updAnalysisSet();
158+
analysisSet.begin(s0);
159+
160+
157161
double t0 = s0.getTime();
158162

159163
// create the solver given the input data
@@ -188,6 +192,7 @@ void IMUInverseKinematicsTool::runInverseKinematicsWithOrientationsFromFile(
188192
model.getVisualizer().show(s0);
189193
model.getVisualizer().getSimbodyVisualizer().setShowSimTime(true);
190194
}
195+
int step = 0;
191196
for (auto time : times) {
192197
s0.updTime() = time;
193198
ikSolver.track(s0);
@@ -201,16 +206,19 @@ void IMUInverseKinematicsTool::runInverseKinematicsWithOrientationsFromFile(
201206
else
202207
log_info("Solved at time: {} s", time);
203208
// realize to report to get reporter to pull values from model
209+
analysisSet.step(s0, step++);
204210
model.realizeReport(s0);
205211
}
206212

207213
auto report = ikReporter->getTable();
208214

209-
auto eix = orientationsFileName.rfind(".");
210-
auto stix = orientationsFileName.rfind("/") + 1;
211-
212215
IO::makeDir(get_results_directory());
213-
std::string outName = "ik_" + orientationsFileName.substr(stix, eix-stix);
216+
std::string outName = get_output_motion_file();
217+
if (outName.empty()) {
218+
auto eix = orientationsFileName.rfind(".");
219+
auto stix = orientationsFileName.rfind("/") + 1;
220+
outName = "ik_" + orientationsFileName.substr(stix, eix - stix);
221+
}
214222
std::string outputFile = get_results_directory() + "/" + outName;
215223

216224
// Convert to degrees to compare with marker-based IK

OpenSim/Tools/InverseKinematicsTool.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,8 @@ InverseKinematicsTool::InverseKinematicsTool() : InverseKinematicsToolBase() {
7070
*
7171
* @param aFileName File name of the document.
7272
*/
73-
InverseKinematicsTool::InverseKinematicsTool(const string &aFileName, bool aLoadModel) :
74-
InverseKinematicsToolBase(aFileName, true)
75-
{
73+
InverseKinematicsTool::InverseKinematicsTool(const string &aFileName, bool aLoadModel) :
74+
InverseKinematicsToolBase(aFileName, aLoadModel) {
7675
constructProperties();
7776
updateFromXMLDocument();
7877
}
@@ -86,7 +85,6 @@ void InverseKinematicsTool::constructProperties()
8685
constructProperty_IKTaskSet(IKTaskSet());
8786
constructProperty_marker_file("");
8887
constructProperty_coordinate_file("");
89-
constructProperty_output_motion_file("");
9088
constructProperty_report_marker_locations(false);
9189
}
9290

OpenSim/Tools/InverseKinematicsToolBase.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ class OSIMTOOLS_API InverseKinematicsToolBase : public Tool {
119119
// Make range -Infinity to Infinity unless limited by data
120120
range[0] = -SimTK::Infinity;
121121
constructProperty_time_range(range);
122+
constructProperty_output_motion_file("");
122123
constructProperty_report_errors(true);
123124
};
124125

0 commit comments

Comments
 (0)