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

Forward Simulation of Stance Phase

Creating a Muscle-Driven Simulation of the Stance Phase of Gait

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.

Opening the Model and Viewing the Data

  1. Load the leg6dof9muscles.osim model from the examples directory (e.g., examples \Leg6Dof9Musc)
  2. Preview the kinematics and ground-reaction forces with the model
    1. Load the motion file leg69_IK_stance.mot and hit play.
    2. Under File, choose Preview Motion Data and select leg69_stance_grf.mot
    3. Leg6Dof9Musc.osim: The model we'll use in this exercise is of a right leg and pelvis with 6 coordinates and 9 muscles. Sync the two motions by selecting both motions: hold the control key, right click to sync motions, and hit play.

Inverse Dynamics

Use Inverse Dynamics to determine the amount of residual force that is required for the model's dynamics to be consistent with applied ground reaction forces:

  1. Right click the leg69 model and make it the current model.
  2. Launch the Inverse Dynamics tool.
  3. Under Input select Motion→Loaded motion→ ik trial.
  4. Check the box to filter kinematics at 6Hz.
  5. Specify the time range as 0.5s to 1.5s, the period in which ground reaction forces are defined.
  6. Specify an output directory (e.g. <YourWorkingDir>\Stance\ID_Results)
  7. Select the External Loads tab and check the External Loads box.
  8. Edit the External Loads settings by clicking the pencil icon.
    1. Select the leg69_stance_grf.mot as the Force data file. This file describes the force applied at the foot's center of pressure.
    2. Select leg69_IK_stance.mot as the Kinematics for external loads.
    3. Select Filter kinematics and specify 6Hz.
    4. Forces listed in the motion file are added as individual forces by hitting the Add button.
      1. Provide a name (e.g., "Right_GRF")
      2. Applied to body (e.g., calcn_r)
      3. Check Applies Force and select Point Force
      4. Force Columns select "ground_force_vx", y & z selected automatically
      5. Point Columns select "ground_force_px"
      6. The GRF free moment is a torque, so check "Applies Torque"
      7. Torque Columns, scroll down and select "ground_torque_x"
      8. Both the GRF and CoP are expressed in the ground (lab) frame
      9. Click OK
    5. Hit Save and enter a filename for the External Force (e.g., leg69_right_GRF.xml)
  9. Save settings (e.g. leg69_Setup_ID_stance.xml), then hit Run.
  10. Plot the forces acting on the pelvis (e.g., pelvis_tilt_moment, pelvis_tx_force, etc.) and the net joint moments for the hip, knee and ankle from inverse_dynamics.sto.  Which is the largest residual? What accounts for the large residual forces?

Residual Reduction Algorithm

Use the RRA tool to reduce residuals. In other words, adjust the model to compensate for model inconsistency with the applied GRFs.

  1. Launch the Reduce Residuals tool.
  2. Specify Desired Kinematics, which is the IK motion leg69_IK_stance.mot.
  3. Check the box to filter kinematics at 6Hz.
  4. Specify the tracking tasks for RRA. Specify the task file provided in Stance/Reference/ leg69_Tracking_Tasks.xml. This file specifies the coordinates to be tracked and the corresponding weights. Use an XML editor (e.g., Notepad++) to view the tasks.
  5. Specify Actuator control constraints file leg69_muscles_residuals_motors_control_limits.xml. These constraints define the maximum and minimum control limits for all actuators.
  6. Check "Adjust model". Click on the folder icon, make sure you are in the Stance folder, and specify a new model name (e.g. leg6dof9musc_adjusted_COM_pelvis.osim). Click Save.
  7. Specify the Body COM to adjust as pelvis. The center-of-mass of this body will be adjusted to reduce residual. Typically we choose the segment incorporating the torso.
  8. Specify the time range as 0.5s to 1.5s.
  9. Specify an output directory (e.g. Stance\RRA)
  10. Select the Actuators and External Loads tab and choose "Replace model's force set" to replace the model's muscles with residual and joint motor actuators since we are creating a torque-driven simulation. Click Edit, then click Add. Then click the folder button next to the red text box. Select leg69_RRA_residuals_motors.xml. Click OK.
  11. Check the External Loads box and specify the file you created for Inverse Dynamics (e.g. leg69_right_GRF.xml).
  12. Save your settings to an RRA setup file (e.g., leg69_Setup_RRA_stance.xml).
  13. Hit Run.  
    1. Why does the model "float" down and up?
  14. With the original model, preview the model motion with the GRF again.  
    1. Are all of the forces being applied correctly? 
    2. Thinking about this model and motion, what time range of the gait should you restrict your RRA analysis?
  15. Repeat RRA with the original model over the new time interval (and save the new settings). Close the RRA Tool. 
    1. Does the model still "float" up or down? If so, what else could be causing this?
  16. Open up the messages window and locate the recommendation from the last run of RRA (e.g., "dmass = 44.037"). Note, the units are in kilograms (kg). 
    1. What is the recommended mass adjustment?Why would the mass adjustment be so large?
  17. Edit the adjusted model to make the recommended mass adjustments by RRA to the pelvis body.
    1. To make mass adjustments open the Property Editor (Window→Properties). Navigate to the pelvis Body of the adjusted model. Edit the mass of the pelvis and save the model. Alternatively, use an XML editor to edit the model file.
    2. Rename the model in the Navigator window (e.g. leg6dof9musc_adjusted) by right clicking on the current model name and selecting Rename.
  18. Re-run RRA with the adjusted model. Be sure to close and re-open the RRA Tool so you are working on the adjusted model.
    1. Is the mass adjustment suggested by RRA smaller than before?
  19. Plot the RRA residual actuator forces (i.e., MZ, FX, FY) from leg6dof9musc_Actuation_Force.sto.
    1. How do they compare tothe forces acting on the pelvis from your ID results?
  20. Plot tracking kinematics outputted by RRA from leg6dof9musc_Kinematics_q.sto vs. kinematics from IK. You can also get the tracking error values directly from the file leg6dof9musc_pErr.sto.
    1. Which coordinates have large tracking errors?
  21. Increase the tracking task weights for coordinates that show poor tracking (via Edit → File). Decrease the tracking weight for coordinates that are within a degree, since the optimizer can use this to reduce residuals. Note: The plotter will display most angles in radians. 1 degree = 0.017 radians. See Simulation with OpenSim - Best Practices for more information about getting good results from RRA.
  22. Re-run RRA. Repeat steps 19 and 20 to check the residual forces and tracking errors.
    1. Are the residual forces and tracking improved?

Computed Muscle Control

Use the Computed Muscle Control (CMC) Tool to determine the muscle excitations, activations and forces that generate a forward dynamics simulation of the stance-phase of gait.

  1. Load the final adjusted model from RRA
  2. Consider the residual and motor actuators necessary for CMC (e.g., modify leg69_RRA_residuals_motors.xmlusing Edit→File or an XML editor)
    1. With muscles present, reduce the optimal force of joint motors to 1 so that they are penalized during CMC and muscles are favored to generate joint moments.
    2. Save the edited the actuators as a new file (e.g., leg69_CMC_residuals_motors.xml).
  3. Launch the CMC Tool.
  4. Specify Desired Kinematics as output from RRA (e.g., leg6dof9musc_Kinematics_q.sto). Note, no filtering is required as the kinematics are smooth since they result from a simulation.
  5. Apply tracking tasks. Use the same tasks file as for RRA.
  6. Include limits on muscle actuators by using leg69_muscles_residuals_motor_control_limits.xmlas Actuator constraints. Open the file in an XML editor to compare with the Actuator constraints used for RRA.
    1. What is the difference between the actuator constraints file used in CMC and the file for RRA?
  7. Define time range for the stance simulation (use the same range you determined from Step 14 in RRA).
  8. Specify the output directory (e.g., Stance\CMC).
  9. Under the Actuators and External Loads tab, select "Append to the model's force set" to include joint motor and residual actuators in addition to existing muscles in the model. Use the Edit button to specify leg69_CMC_residuals_motors.xml to be appended.
  10. Specify the external loads (same as for RRA).
  11. Save your settings to a file.
  12. Run CMC. If CMC does not execute completely, review the tips and tricks in the handout for help with troubleshooting.
  13. Plot the muscle activation patterns from the states file, leg6dof9musc_added_mass_states.sto. Tip: Using the pattern filter in the plotter selection tool, type "activation" to quickly select the activations.
    1. Are the simulated activations close to what you expected?
  14. Check the quality of the simulation by examining the tracking errors, the residual forces, and the motor moments (i.e., reserves). The motor moments are in leg6dof9musc_added_mass_Actuation_force.sto
    1. How do the kinematics compare to the IK solution for stance?How big are the residuals forces from CMC? How do they compare to residuals from RRA? Are the motor moments (i.e., reserves) at the hip, knee and ankle significant?Are the residuals below 2% of body-weight?
  15. If time permits, run a forward simulation with the controls from CMC and initial states from CMC. Running Forward Dynamics after CMC is a method of verifying that the controls from CMC generate a forward simulation consistent with the observed kinematics and applied GRFs.
    1. How do the kinematics from Forward compare to the original IK solution?

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.