You are viewing the documentation for OpenSim 2.4. Are you looking for the latest OpenSim 4.0 Documentation?

Forward Simulation of Swing Phase

To present some of the tools and capabilities of OpenSim, we will use a simplified model (leg6dof9muscles.osim) throughout this example. The model consists of the pelvis, thigh, shank, and foot segments along with the psoas major, gluteus maximus, rectus femoris, vastus intermedius, biceps femoris long head, biceps femoris short head, tibialis anterior, medial gastrocnemius, and soleus muscles. This simple model is not intended for research.

You can find the model and the necessary files for this example in the directory where you installed OpenSim (e.g. C:\OpenSim2.4\examples\Leg6Dof9Musc). The files for Part One are in the “Swing” folder.

The first part of the exercise is broken into the following three steps:

You can also download a pdf of this page by clicking on the Tools link in the top right corner and selecting "Export to PDF".

Simulation of Swing using the Muscle Excitation Editor

First, try to come up, by hand, with a set of muscle excitations that will generate swing phase motion of the leg during gait.

  1. Load the model leg6dof9muscles.osim.
  2. Load the motion file (File->Load Motion) with the results of Inverse Kinematics (leg69_IK_swing.mot) and play it in the GUI.
  3. Stop the motion and rewind to the beginning. Under the Coordinates tab press “Poses” and select “Set Default”, which will define the default pose of the model to match the start of the IK solution.
  4. Launch the Forward Dynamics tool (Tools->Forward Dynamics).
  5. Check “Solve for equilibrium for actuator states”, which will find initial muscle states such that the muscle-fiber and tendon forces are in equilibrium. Controls and States inputs are not required.
  6. Specify the time range corresponding to the IK motion (0.117s to 0.617s).
  7. Specify an output directory (e.g. <YourWorkingDir>/Swing/FWD_no_controls)
  8. Save your settings to a file (e.g. leg69_Setup_FWD_no_controls.xml).
  9. Press Run. This will run forward dynamics and output simulated states and applied controls to the specified directory.
  10. Replay the resulting motion, and notice that the model falls since there are no ground reaction forces to oppose gravity.
  11. Lock the pelvis coordinates (pelvis_tilt, pelvis_tx, pelvis_ty) to prevent the model from falling and rerun Forward Dynamics, loading the settings that you saved in step 8.
  12. Replay the resulting motion, then open the plot tool.  How do the kinematics compare to the inverse kinematics solution?
  13. Now lets try adding a muscle excitation.  By exciting a single muscle in early swing, can you exceed the hip flexion in the inverse kinematics motion file? Modify the controls file as follows:
    1. Open the Forward Tool and select the controls from the previous output directory (e.g. “FWD_no_controls/leg6dof9musc_controls.sto”) by clicking on the folder icon.
    2. Click the pencil icon and then select a muscle that will generate hip flexion and hit OK to edit that muscle’s excitation pattern. 
    3. Modify the selected muscle’s excitation in the window that appears.  Hit the help button if you need a guide to using the Excitation Editor.
    4. Press the “Save As” button to save your changes to controls to a file (e.g. “controls_<muscle>.xml”)
    5. Close the excitation editor and load the modified controls file by pressing the folder icon next to the Controls box.
    6. Make sure “Solve for equilibrium actuator states is still checked.”
    7. Specify a new output directory (e.g. Swing/FWD_<muscle_name>) for the one muscle excited and hit Run.
    8. By exciting a second muscle in late swing, can you avoid hyper-extending the knee and achieve the hip flexion from inverse kinematics?  Repeat the steps above to generate a new controls file and forward simulation.
    9. By exciting a third muscle, can you avoid excessive ankle plantarflexion? If yes, what muscle?
    10. Repeat this process, adjusting the muscles excitations to create a motion as close to the observed swing as possible.

Static Optimization for Swing Phase

Use static optimization to estimate the muscle excitations for swing:

  1. Launch the Static Optimization Tool
  2. Under Input, select Motion -> From File and open leg69_IK_swing.mot
  3. Check the box to filter coordinates at 6Hz
  4. Check “Use muscle force-length-velocity relation”, which will estimate muscle force taking into account the length and velocity of the muscle fiber assuming that muscle-tendon length changes are due to fiber-length change (i.e. assuming a rigid tendon).
  5. Define the time range.
  6. Specify an output directory for static optimization activations and forces and hit Run.
  7. Compare the muscle activation patterns from static optimization to the activations  from the forward simulation with your best set of controls (these can be found in the states.sto file from the forward simulation).

Now use the muscle activations from Static Optimization to generate a new Forward Dynamics simulation of swing:

  1. Launch the Forward Dynamics Tool.
  2. Select the controls file from Static Optimization.
  3. Check “Solve for equilibrium for actuator states”.
  4. Specify the time range of the motion.
  5. Specify the results directory (e.g. Swing/FWD_SO).
  6. Compare the resulting kinematics to the inverse kinematics swing motion.
  7. Compare the resulting activations to static optimization activations. 

CMC for Swing Phase

  1. Launch the Computed Muscle Control Tool.
  2. Under Input, select leg69_IK_swing.mot as the desired kinematics.
  3. Check the box to filter coordinates at 6Hz.
  4. Specify tracking tasks (hip, knee, and ankle tracking and their weightings) by loading the tracking tasks file (leg69_CMC_Swing_Tracking_Tasks.xml).
  5. Include actuator control constraints that define the control limits on muscles (leg69_muscles_control_limits.xml).
  6. Specify the time range of the motion corresponding to the swing motion from IK.
  7. Choose a CMC look-ahead window that is the approximate time in which muscles can change their output force in response to a change in input controls (0.01s).
  8. Specify results directory and hit Run.
  9. Compare the resulting kinematics to the swing motion from IK.
  10. Compare the CMC activations to static optimization activations
  11. Run a forward simulation with the controls from CMC and initial states from CMC (e.g. CMC/leg6dof9musc_states.sto) and compare resulting kinematics to IK.
 

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.