Skip to content

Commit

Permalink
Merge pull request #3896 from AllisonJohn/moco_inverse_trajectory
Browse files Browse the repository at this point in the history
Added accessor for kinematics from `MocoInverse` init
  • Loading branch information
nickbianco authored Aug 30, 2024
2 parents 38fed30 + 59258a4 commit 43e2c6b
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 0 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG_MOCO.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ Moco Change Log

1.4.0
-----
- 2024-08-30: Added `MocoInverse::initializeKinematics()` to allow users to retrieve kinematics after
converting the `MocoInverse` to a `MocoStudy`.

- 2024-08-26: Changed all `printDescription()` and `printDescriptionImpl()` methods to log at level info
instead of cout.

Expand Down
4 changes: 4 additions & 0 deletions OpenSim/Moco/MocoInverse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ void MocoInverse::constructProperties() {

MocoStudy MocoInverse::initialize() const { return initializeInternal().first; }

TimeSeriesTable MocoInverse::initializeKinematics() const {
return initializeInternal().second;
}

std::pair<MocoStudy, TimeSeriesTable> MocoInverse::initializeInternal() const {

// Process inputs.
Expand Down
1 change: 1 addition & 0 deletions OpenSim/Moco/MocoInverse.h
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ class OSIMMOCO_API MocoInverse : public MocoTool {
}

MocoStudy initialize() const;
TimeSeriesTable initializeKinematics() const;
/// Solve the problem returned by initialize() and compute the outputs
/// listed in output_paths.
MocoInverseSolution solve() const;
Expand Down
12 changes: 12 additions & 0 deletions OpenSim/Moco/Test/testMocoInverse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,19 @@ TEST_CASE("MocoInverse Rajagopal2016, 18 muscles", "[casadi]") {
CHECK(med_gas_l_excitation[i] <=
Approx(0.1).margin(1e-6));
}
}

SECTION("initializeKinematics") {
auto kinematics = inverse.initializeKinematics();
// check that some of the expected columns are there
CHECK_NOTHROW(kinematics.getColumnIndex(
"/jointset/hip_r/hip_rotation_r/value"));
CHECK_NOTHROW(kinematics.getColumnIndex(
"/jointset/ground_pelvis/pelvis_tilt/value"));
CHECK_NOTHROW(kinematics.getColumnIndex(
"/jointset/walker_knee_r/knee_angle_r/speed"));
CHECK_NOTHROW(kinematics.getColumnIndex(
"/jointset/back/lumbar_extension/speed"));
}
}
// Next test_case fails on linux while parsing .sto file, disabling for now
Expand Down

0 comments on commit 43e2c6b

Please sign in to comment.