opensim-org / opensim-core

SimTK OpenSim C++ libraries and command-line applications, and Java/Python wrapping.
https://opensim.stanford.edu
Apache License 2.0
758 stars 307 forks source link

`Bhargava2004SmoothedMuscleMetabolics` does not set muscle mass during deserialization #3783

Open nickbianco opened 1 month ago

nickbianco commented 1 month ago

When adding a muscle to a Bhargava2004SmoothMuscleMetabolics component, the muscle mass is calculated based on either the provided muscle mass or specific tension and stored in a member variable via Bhargava2004SmoothedMuscleMetabolics_MuscleParameters::setMuscleMass(). Example here.

However, during deserialization, setMuscleMass() is never called for all connected muscles leaving the muscle masses set to zero, which obviously produces incorrect metabolic cost values.

One solution: within Bhargava2004SmoothedMuscleMetabolics::extendFinalizeFromProperties() loop through all muscle parameters in the list property and for each call setMuscleMass().