WELCOME TO THE NEW PLATFORM FOR THE OPENSIM DOCUMENTATION

Remember to update your bookmarks with our new URL.
If you find missing content or broken links, let us know: opensim@stanford.edu


Part I: Leg Muscle Force Estimation in Swing

All example files are included in the Model folder "Leg6Dof9Musc" included with the OpenSim installation.

Model


LegSwingStancePic.png

This is a simplified, single-leg model (leg6dof9musc.osim – 6 degrees of freedom, 9 muscles) that is packaged with the OpenSim distribution. The leg model consists of 7 bodies representing four physiological segments (pelvis, thigh, shank, and foot). The configuration of the system is described by 6 generalized coordinates (pelvis_tilt, pelvis_tx, pelvis_ty, hip_flexion_r, knee_angle_r, and ankle_angle_r). The musculoskeletal forces are generated by 9 muscles (psoas major, gluteus maximus, rectus femoris, vastus intermedius, biceps femoris long head, biceps femoris short head, tibialis anterior, medial gastrocnemius, and soleus).

This simple model is not intended for research.






A. Explore the model and the Forward Dynamics Tool

Objective: Visualize an inverse kinematic solution of the swing phase using the OpenSim GUI. Run a forward dynamic simulation of the swing phase with no muscle control.

Open the leg model, load the motion, and view the animation.

Use the File menu in the OpenSim GUI to open the 6-degree-of-freedom, 9-muscle leg model file (leg6dof9musc.osim) and load the swing motion file (leg69_IK_swing.mot from the Swing folder). The loaded motion will appear under the Motions tree in the Navigator panel. Animate the swing phase motion using the movie controls located above the view pane.

In the Navigator panel, rename the motion from Results to IK so it is distinct from the motions we will be generating below.

Stop the motion and reset the player to the first time step. In the Coordinates tab, set the current pose of the model (i.e., the initial pose of the inverse kinematics (IK) solution) as the default pose by clicking “Poses >” and selecting “Set Default”. Save the model after changing the default parameters.

Use the Forward Dynamics Tool to create a simulation of the system with no muscle controls.

Read the following set of pages on How Forward Dynamics Works.

Open the Forward Dynamics Tool by selecting “Forward Dynamics...” from the Tools menu. Configure the tool as follows:

  • In the Input pane, check “Solve for equilibrium for actuator states”, which will equilibrate the fiber and tendon forces in each muscle at the initial time step.
  • In the Time pane, specify the time range corresponding to the IK motion (0.117 to 0.617 seconds).
  • In the Output pane, create a new directory in the Swing folder (e.g., <YourWorkingDir>\Swing\FWD_No_Controls).
  • Save your settings to a file (e.g., leg69_Setup_Forward_No_Controls.xml).
  • Run the simulation. Replay the resulting motion using the movie controls.
  • Close the tool.
  • In the Navigator, rename the motion to FWD_unlocked.

Lock the pelvis coordinates and plot simulation results.

In this forward simulation, the model simply falls because there are no forces to oppose gravity. In the Coordinates tab, lock the pelvis coordinates (pelvis_tilt, pelvis_tx, and pelvis_ty) to prevent the model from falling. Re-run the Forward Dynamics Tool, making sure to use "FWD_locked" in the names of the output folder, the settings file, and the resulting motion.

Open the plotter by selecting "Plot..." from the Tools menu. The X and Y quantities for the plot are selected in the Curve Add panel. Data can be loaded by clicking "Y-Quantity..." and selecting the "Load file..." option (note that the generalized coordinates will appear at the top of the list and the generalized speeds are suffixed with '/speed' ("_u" in versions before 4.0)).


 Click here to show questions for Part I - A…

  1. From the IK results, plot hip flexion, knee angle, and ankle angle as functions of time.
  2. From the FWD_locked results, plot hip flexion, knee angle, and ankle angle as functions of time.
  3. Discuss the difference in joint trajectories between the inverse kinematic and forward dynamic simulations.
  4. Examine the pelvis_tilt, pelvis_tx, and pelvis_ty coordinates of the IK solution, and discuss the effect of locking the coordinates in the forward simulation.

B. Simulate swing phase with manually selected excitations

Objective: Using the Excitation Editor in the OpenSim GUI, find a set of muscle excitations that will match the given swing phase motion.

Make sure that the pelvis coordinates (pelvis_tilt, pelvis_tx, and pelvis_ty) are locked before proceeding with the remaining sections.

In the previous forward dynamic simulation, no controls were specified for the muscle actuators. As a result, no active muscle forces were generated.

Use the Excitation Editor to generate a set of muscle excitations that track the IK solution.

Read the page on how to use the Excitation Editor to learn how to select and change points on a muscle excitation curve.

Two helper files for setting up the excitation editing can be found in the Swing folder: leg69_Forward_Default_Controls.xml and leg69_Forward_Default_States.sto. The first file, leg69_Forward_Default_Controls.xml, adds control information for each muscle in the model. The controller is defined by a set of control nodes (time and value pairs) that are linearly interpolated over time to form the muscle excitation signal. These nodes can be edited using the Excitation Editor. The second file, leg69_Forward_Default_States.sto, contains the initial coordinates, generalized velocities, muscle activations, and muscle fiber lengths that completely specify the starting state used in forward simulations.

Open the Forward Tool and configure the simulation as follows:

  • In the Input pane, for Controls, select the XML file that contains the controls of the forward simulation (e.g., leg69_Forward_Default_Controls.xml).
  • In the Input pane, for Initial State, select the storage file that contains the initial states of the forward simulation (e.g., leg69_Forward_Default_States.sto).
  • Open the Excitation Editor by clicking on the pencil next to the Controls textbox. From the list of muscles, select a muscle capable of generating hip flexion and click OK.
  • Increase the excitation of the muscle as desired.
  • Save the excitations to a controls file (e.g., leg69_Forward_Controls_<muscle_name>.xml).
  • In the Input pane, for Controls, select the newly created XML file.
  • Check the “Solve for equilibrium for actuator states” box.
  • Check that the time range matches the original time range for IK.
  • Specify a new output directory (e.g., Swing\FWD_<muscle_name>).
  • Save your settings to a file (e.g., leg69_Setup_Forward_<muscle_name>.xml).
  • Run the simulation and compare the values of the hip flexion, knee angle, and ankle angle coordinates to the inverse kinematics solution.
  • Close the tool.

Excite three muscles to minimize the error of the hip flexion, knee angle, and ankle angle coordinates.

Do not spend a lot of time trying to match the IK solution: it is challenging to do by hand and there are OpenSim Tools that do this (which we will explore below). Simply aim to reduce the error relative to the "FWD_locked" simulation (i.e., with no muscle excitations).

  • By exciting a single muscle in early swing, reduce the error of the hip flexion coordinate in the forward simulation.
  • By exciting a second muscle along with your previous excitation, reduce the error of the hip flexion and knee angle coordinates.
  • By exciting a third muscle, reduce the error of the hip flexion, knee angle, and ankle angle coordinates.


 Click here to show questions for Part I - B…

  1. To match the hip flexion, knee angle, and ankle angle coordinates of the inverse kinematic solution, which three muscles did you excite during the forward dynamic simulation?
  2. Continue adjusting your muscle excitations until you are satisfied with the tracking. Plot the excitations of your three muscles as functions of time.
  3. Plot the hip flexion, knee angle, and ankle angle coordinates for the IK solution and your forward solution together.
  4. Discuss your observations regarding the challenge of tracking trajectories with a forward dynamic simulation.

C. Simulate swing phase with activations from Static Optimization (SO)

Objective: Using the Static Optimization Tool, find a set of muscle controls for the swing phase. Use the resulting controls in a forward dynamic simulation and compare the results.

Use the Static Optimization Tool to find a set of muscle controls that approximately matches the IK motion.

Read the following set of pages on How Static Optimization Works.

Open the Static Optimization Tool and configure it as follows:

  • In the Input pane, load the leg69_IK_swing.mot file as the Motion.
  • In the Input pane, check the box to filter coordinates and enter a cutoff frequency of 6 Hz.
  • In the Objective Function pane, set the muscle activation exponent to 2.0 and check “Use muscle force-length-velocity relation”.
  • Set the time range to between 0.117 and 0.617 seconds (if it is not already set).
  • Specify the output directory (e.g., Swing\SO).
  • Save your settings to a file (e.g., leg69_Setup_SO.xml).
  • Make sure the pelvis coordinates (pelvis_tilt, pelvis_tx, and pelvis_ty) are locked.
  • Run the tool; close the tool when you are finished.

Use the Forward Dynamic Tool to examine the motion using the estimated muscle controls from Static Optimization.

Run a forward dynamic simulation of the swing phase using the controls generated by Static Optimization. Configure the Forward Dynamics Tool as follows:

  • In the Input pane, for Controls, navigate to the folder containing the results from Static Optimization and select the controls file.
  • In the Input pane, for Initial State, select the storage file that contains the desired initial states (e.g., leg69_Forward_Default_States.sto).
  • Check the “Solve for equilibrium for actuator states” box.
  • Specify the same time range as before.
  • Specify the output directory (e.g., Swing\FWD_SO).
  • Save your settings to a file (e.g., leg69_Setup_Forward_SO.xml).
  • Run the tool; close the tool when you are finished.


 Click here to show questions for Part I - C…

  1. Plot the muscle activation patterns from the Static Optimization results folder, then plot the activations from the Forward simulation with your best set of controls (from Part B). How do the activations compare?
  2. Plot the hip flexion, knee angle, and ankle angle coordinates from the Forward simulation that used controls found by Static Optimization, along with the coordinates from the IK solution. Why does the Forward simulation using the Static Optimization controls diverge from the IK solution?

D. Simulate swing phase with excitations from Computed Muscle Control (CMC)

Objective: Using the CMC Tool, find a set of muscle controls for the swing phase. Use the resulting controls in a forward dynamic simulation and compare the results.

Use the Computed Muscle Control (CMC) Tool to find a set of muscle controls that approximately matches the IK motion.

Read the following set of pages on How Computed Muscle Control Works.

Open the CMC Tool and configure it as follows:

  • In the Input pane, specify leg69_IK_swing.mot as the desired kinematics.
  • In the Input pane, specify leg69_CMC_Swing_Tracking_Tasks.xml as the tracking task.
  • Check the box to filter the coordinates and set the cutoff frequency to 6 Hz.
  • Include actuator control constraints that define the muscle control limits (e.g., leg69_muscles_control_limits.xml).
  • Set the time range to between 0.117 and 0.617 seconds (if it is not already set).
  • Choose a “CMC look-ahead window” that is the approximate time in which muscles can change their output forces in response to a change in input controls (use 0.01s).
  • Specify the output directory (e.g., Swing\CMC).
  • Save your settings to a file (e.g., leg69_Setup_CMC.xml).
  • Make sure the pelvis coordinates (pelvis_tilt, pelvis_tx, and pelvis_ty) are locked.
  • Run the tool; close the tool when you are finished.

Use the Forward Dynamics Tool to examine the motion using the estimated muscle controls from CMC.

Run a forward dynamic simulation of the swing phase using the controls generated by CMC. Configure the tool as follows:

  • In the Input pane, for Controls, select the controls file generated by CMC.
  • In the Input pane, for Initial State, select the states file generated by CMC.
  • Check the “Solve for equilibrium for actuator states” box.
  • Specify the output directory (e.g., Swing\FWD_CMC).
  • Save your settings to a file (e.g., leg69_Setup_Forward_CMC.xml).
  • Run the tool; close the tool when you are finished.


 Click here to show questions for Part I - D…

  1. Plot the hip flexion, knee angle, and ankle angle coordinates from the CMC solution along with the coordinates from the IK solution.
  2. Plot the hip flexion, knee angle, and ankle angle coordinates from the Forward simulation that used controls found by CMC, along with the coordinates from the IK solution. Are the simulated trajectories better or worse than the Static Optimization results? What is responsible for the difference?



OpenSim is supported by the Mobilize Center , an NIH Biomedical Technology Resource Center (grant P41 EB027060); the Restore Center , an NIH-funded Medical Rehabilitation Research Resource Network Center (grant P2C HD101913); and the Wu Tsai Human Performance Alliance through the Joe and Clara Tsai Foundation. See the People page for a list of the many people who have contributed to the OpenSim project over the years. ©2010-2024 OpenSim. All rights reserved.