This page will feature the code necessary to generate and incorporate our fatigable muscle model.
During this project, we successfully:
- Developed a muscle model which incorporates properties of fatigue, orderly recruitment and fiber composition,
- Created a plugin so that we can visualize our muscle model in the OpenSim GUI,
- Utilized an optimization to identify our fatigue parameters to match experimental data, and
- Created a tug-of-war simulation between a fatigable muscle and a muscle without fatigue properties.
All source code for this project is available for download at https://simtk.org/home/fatigablemuscle.
Development of Fatigable Muscle Model
The following lines in the FatigableMuscle.h header file declare the FatigableMuscle class by extending a Millard2012EquilibriumMuscle.
The FatigableMuscle inherits all properties from the Millard2012EquilibriumMuscle. The following code in FatigableMuscle.h declares additional properties of the FatigableMuscle.
Default constructor & constructProperties()
The constructProperties function sets all properties of the muscle to the default values. The default constructor does not modify any of these values.
Other available constructors
There are three other available constructors for the Fatigable Muscle, shown and described below.
New model states
Four new states are added to the model:
- Target activation
- RestingMotorUnits (this is not an independent state, but is added in for debugging purposes)
Computation of state derivatives
The new state variable derivatives are computed based on a function that governs the recruitment of resting fibers to an active state based on the current muscle excitation and activation and the muscle fatigue parameters.
Compute activation factor
The activation factor is meant to represent orderly recruitment. The code for calculating the piecewise, C2-continuous cubic spline is given below.
Compute initial fiber equilibrium
Currently, this method is overridden from the Millard2012EquilibriumMuscle class, with the motor units states set to fixed values. This will be changed in the future.
Fatigable Muscle Plugin Files
Note that, to use the fatigable muscle plugin in OpenSim, you only need to download the .dll file which has been added as an attachment to this page. However, if you would like to build the plugin yourself and make any necessary changes, we have the code to do so shown below.
To build the plugin, you will want to include the same source file for the fatigable muscle given above. You must also include osimPluginDLL.h and RegisterTypes_osimPlugin.h, which are files that can be copied over from other OpenSim Plugin examples.
In addition, you must make one small change to the fatigable muscle header file, which will build the FatigableMuscle into a library which can be used in the GUI.
Finally, you must include the source code RegisterTypes_osimPlugin.cpp. This file can also be copied from an OpenSim Plugin example, with one minor modification which is shown below.
Fatigable Muscle Optimization for Fatigue Parameters
The code necessary to run the optimization is included below. Note that, to run an optimization, you must also include the header files osimPluginDLL.h, RegisterTypes_osimPlugin.h, FatigableMuscle.h, and the source files FatigableMuscle.cpp and RegisterTypes_osimPlugin.cpp.
Optimization source code
The optimizer tunes three parameters: the fatigue rate (F), recovery rate (R), and recruitment time constant (τ). The objective function is an RMS error between the percent maximum force generated during an isometric contraction over 60 seconds and experimental data on the fatigue of the thumb adductor policis muscle collected by Hainaut and Duchateau.
Fatigable Muscle Tug-of-War Example
The code for building the tug-of-war example is included in the attachments and in the OpenSim sdk folder. To modify the example to include the FatigableMuscle model instead, use the following code.