Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added accessor for kinematics from MocoInverse init #3896

Merged
merged 3 commits into from
Aug 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading