Skip to content

Commit 3103818

Browse files
authored
Refactor ik solver interface (#2855)
Refactor InverseKinematicsSolver to not make a copy of passed in References, allow clients to add data to OrientationsReference after solver is created.
1 parent 9262441 commit 3103818

27 files changed

+966
-188
lines changed

Applications/IK/test/testIK.cpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,8 @@ void compareMotionTables(const TimeSeriesTable& report,
342342
auto found = std::find(stdLabels.begin(), stdLabels.end(), label);
343343
if (found != stdLabels.end()) {
344344
// skip any pelvis translations
345-
if (found->find("pelvis_t") == std::string::npos) {
345+
if (found->find("pelvis_t") == std::string::npos ||
346+
label.length() != 9) {
346347
index = (int)std::distance(stdLabels.begin(), found);
347348
}
348349
}
@@ -373,12 +374,11 @@ void testInverseKinematicsSolverWithOrientations()
373374
auto orientationsData = convertMotionFileToRotations(
374375
model, "std_subject01_walk1_ik.mot");
375376

376-
OrientationsReference oRefs(orientationsData);
377-
oRefs.set_default_weight(1.0);
377+
std::shared_ptr<OrientationsReference>
378+
oRefs(new OrientationsReference(orientationsData));
379+
oRefs->set_default_weight(1.0);
378380

379-
const std::vector<double>& times = oRefs.getTimes();
380-
381-
MarkersReference mRefs{};
381+
const std::vector<double>& times = oRefs->getTimes();
382382

383383
SimTK::Array_<CoordinateReference> coordinateRefs;
384384

@@ -397,10 +397,10 @@ void testInverseKinematicsSolverWithOrientations()
397397
SimTK::State& s0 = model.initSystem();
398398

399399
// create the solver given the input data
400-
InverseKinematicsSolver ikSolver(model, mRefs, oRefs, coordinateRefs);
400+
InverseKinematicsSolver ikSolver(model, nullptr, oRefs, coordinateRefs);
401401
ikSolver.setAccuracy(1e-4);
402402

403-
auto timeRange = oRefs.getValidTimeRange();
403+
auto timeRange = oRefs->getValidTimeRange();
404404
cout << "Time range from: " << timeRange[0] << " to " << timeRange[1]
405405
<< "s."<< endl;
406406

@@ -443,16 +443,16 @@ void testInverseKinematicsSolverWithEulerAnglesFromFile()
443443

444444
SimTK::State& s0 = model.initSystem();
445445

446-
MarkersReference mRefs{};
447-
OrientationsReference oRefs("subject1_walk_euler_angles.sto");
446+
std::shared_ptr<OrientationsReference> oRefs(
447+
new OrientationsReference("subject1_walk_euler_angles.sto"));
448448
SimTK::Array_<CoordinateReference> coordRefs{};
449449

450450
// create the solver given the input data
451451
const double accuracy = 1e-4;
452-
InverseKinematicsSolver ikSolver(model, mRefs, oRefs, coordRefs);
452+
InverseKinematicsSolver ikSolver(model, nullptr, oRefs, coordRefs);
453453
ikSolver.setAccuracy(accuracy);
454454

455-
auto& times = oRefs.getTimes();
455+
auto& times = oRefs->getTimes();
456456

457457
s0.updTime() = times[0];
458458
ikSolver.assemble(s0);

0 commit comments

Comments
 (0)