Before you begin working on stance, be sure to unlock the three pelvis coordinates (pelvis_tilt, pelvis_tx, pelvis_ty) that were locked for the swing analysis.
A. Find a set of generalized forces that produce the stance motion using Inverse Dynamics
Objective: Use the Inverse Dynamics Tool in the OpenSim GUI to find a set of applied forces that make the model dynamics consistent with the applied ground reaction forces.
Associate the ground reaction force (GRF) data with the inverse kinematics trial and visualize the results.
Visualize and associate the stance motion with the model file as follows:
- Use the File menu to load the motion file leg69_IK_stance.mot.
- In the Navigator pane, find the motion called "ik trial".
- Right-click "ik trial" and select "Associate Motion Data...".
- Associate the file Stance\leg69_stance_grf.mot with the loaded motion.
- Play the animation to ensure the ground reaction forces have been loaded correctly.
Use the Inverse Dynamics Tool to find a set of generalized forces.
Read the page on How Inverse Dynamics Works to understand how the forces are calculated.
Open the Inverse Dynamics (ID) Tool and configure it as follows:
- In the Input pane, select "Loaded motion" and use the "ik trial" motion from the previous step.
- Check the box to filter the coordinates and set the cutoff frequency to 6 Hz.
- Set the time range to between 0.5 and 1.5 seconds.
- Specify an output directory (e.g., <YourWorkingDir>\Stance\ID).
- Select the External Loads tab and check the External Loads box.
- Edit the External Loads settings by clicking the pencil icon to the right of the textbox.
- Select leg69_stance_grf.mot as the "Force data file". This file describes the force applied at the foot's center of pressure (CoP).
- Select leg69_IK_stance.mot as the "Kinematics for external loads".
- Select "Filter kinematics" and specify a cutoff frequency of 6 Hz.
- Add the forces listed in the motion file by clicking the "Add..." button.
- Provide a name (e.g., "Right_GRF").
- Apply the force to the calcn_r body.
- Check "Applies Force" and select "Point Force".
- Force Columns: select "ground_force_vx" (GRF vector, x coordinate) from the first drop-down box; "ground_force_vy" and "ground_force_vz" will be selected automatically. (The entries with the prefix "1_" correspond to data from the other leg.)
- Point Columns: select "ground_force_px" (point of application, x coordinate) from the first drop-down box; the corresponding "y" and "z" entries will again be populated automatically.
- The GRF free moment is a torque, so check "Applies Torque".
- Torque Columns: select "ground_torque_x", "ground_torque_y", and "ground_torque_z".
- The GRF and CoP are both expressed in the ground (laboratory) frame, so click OK.
- Click "Save..." and enter a filename for the External Force input (e.g., leg69_right_GRF.xml).
- Click "Save..." and enter a filename for the ID settings (e.g., leg69_Setup_ID_stance.xml).
- Run the tool, then close the Inverse Dynamics Tool window.
- Plot the applied forces and torques that act on the pelvis (i.e., pelvis_tilt_moment, pelvis_tx_force, and pelvis_ty_force) as functions of time. The data is in the ID/inverse_dynamics.sto file.
- What does the pelvis_ty_force curve tell you about the force applied during stance?
- Plot the experimentally measured vertical ground reaction forces (ground_force_vy [right leg] and 1_ground_force_vy [left leg]) from the leg69_stance_grf.mot file and the pelvis_ty_force as functions of time.
- How do the ground forces compare to the pelvis_ty_force?
- Given that the model consists of only a single leg and pelvis, in what time range is it reasonable to use this model with the given kinematics and measured forces?
B. Model refinement through residual reduction
Objective: Use the Residual Reduction Algorithm (RRA) Tool to find a new set of model parameters that reduces the residual forces.
Read the pages describing the Residual Reduction Algorithm.
Use the RRA Tool to calculate the size of the residuals.
Open the RRA Tool and configure it as follows:
- In the input pane, set the desired kinematics as the IK motion file (e.g., leg69_IK_stance.mot).
- Check the box to filter kinematics at 6 Hz.
- In the input pane, specify the tracking tasks for RRA (use Stance\leg69_Tracking_Tasks.xml). This file specifies the coordinates to be tracked and the corresponding weights. Use the GUI File Editor or an XML editor (e.g., Notepad++) to view the tasks.
Check "Adjust model". Click on the folder icon, make sure you are in the Stance folder, specify a new model name (e.g., leg6dof9musc_RRA_adjusted.osim), and click Save.
- Make the pelvis the "Body COM to adjust". The center of mass of this body will be adjusted to reduce residuals. Typically, the segment that includes the torso is chosen.
- Specify the time range using your analysis from part A (see Questions: Leg Muscle Force Estimation, Part II, Question A.5).
- Specify an output directory (e.g., <YourWorkingDirectory>\Stance\RRA).
- Go to 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 the "Edit..." button next to the "Additional force set files" textbox, then click "Add". Click the folder button next to the red textbox and select leg69_RRA_residuals_motors.xml. Click OK.
- Check the External Loads box and specify the file you created for Inverse Dynamics (e.g., leg69_right_GRF.xml).
- Save your settings to an RRA setup file (e.g., leg69_Setup_RRA_stance.xml) and click Run.
After each run of the RRA tool, a new model file will be loaded into the navigator (and also printed) where the COM of the pelvis has been automatically adjusted. In the Messages window, the RRA tool also provides a set of estimated changes to the mass and the COM for all of the segments which would further reduce the residuals needed to match the experimental kinematic and force data.
- Why does the pelvis translate substantially in the y-direction (pelvis_ty coordinate) during the simulation?
- Plot the RRA residual actuator forces (i.e., MZ, FX, and FY) from leg6dof9musc_controls.sto.
- Open the Messages pane and locate the recommended overall mass adjustment from the last run of RRA (e.g., "pelvis: orig mass = 10.7538, new mass = xxxxx"). Note that the units are in kilograms (kg). What is the recommended mass adjustment? Why would the mass adjustment be so large?
C. Finalize the model through iteration of RRA
Objective: Create a new model using the output of the RRA Tool. Iteratively run RRA on each new model, adjusting only the pelvis mass and COM location.
Use the Navigator to edit the mass properties of the pelvis as recommended by the RRA Tool.
When RRA is complete, a new model with an adjusted pelvis COM will be loaded into the navigator. However, the mass of the pelvis is not adjusted by the Tool and you will need to manually adjust the mass of the body.
- In the Navigator pane, expand the Bodies tree and select pelvis.
- In the Properties Editor, adjust the mass as recommended by the RRA Tool.
- Rename the model in the Navigator pane (e.g., leg6dof9musc_adj) by right-clicking on the current model name and selecting "Rename...".
- Click "Save As..." and save the model with a new name (e.g., leg6dof9musc_RRA_adjustedmass.osim).
Perform several iterations of running RRA and adjusting the model until the residual forces and tracking errors have stabilized.
- Re-run RRA with the adjusted model making sure to close and re-open the RRA Tool to ensure the most recent adjusted model is always used.
- Adjust the pelvis COM and mass in accordance with the RRA Tool output messages.
- Increase the tracking task weights for coordinates that show poor tracking.
- Decrease the tracking task weights for coordinates that are within 1 degree, since the optimizer can then use these coordinates to reduce the residual forces.
- Iterate until the requested change in pelvis mass is less than 1 kg and the residual forces and coordinate errors follow the suggested thresholds in the table at the bottom of the Getting Started with RRA page.
You should see the pelvis mass stabilize after about 5 iterations. If you are completing this exercise for a course, don't spend a lot of time aiming for perfection; "OKAY" results are okay.
- For your final RRA iteration, plot the tracking error values from the RRA/leg6dof9musc_pErr.sto file.
- For your final RRA iteration, list the weights of all coordinates in tracking tasks.
- For your final RRA iteration, which coordinate has the maximum tracking error and what is the maximum tracking error value?
D. Forward simulation of stance with CMC
Objective: Use the CMC Tool to determine a set of muscle excitations, activations, and forces that generate a forward dynamic simulation of the stance phase of gait.
Configure the actuators used in the CMC Tool.
Create a new actuator file that penalizes the use of residual motors:
- Ensure you have loaded your final model from the previous section on RRA.
- From the Edit menu, select "File (.xml)..." and open the leg69_RRA_residuals_motors.xml file, which contains information on the residual and motor actuators necessary for CMC.
- Reduce the optimal force of the joint motors to 1 so that they are penalized during CMC and muscles are favored to generate joint moments.
- Save the edited actuators as a new file (e.g., leg69_CMC_residuals_motors.xml).
Use the CMC Tool to calculate the muscle excitations, activations, and forces of the stance phase.
Open the CMC Tool and configure it as follows:
- In the Input panel, specify the desired kinematics as the output from RRA (e.g., leg6dof9musc_Kinematics_q.sto).
- Note that no filtering is required: the kinematics are smooth because they resulted from a simulation.
- Ensure you are using the adjusted RRA model and the corresponding kinematics.
- Apply tracking tasks. Use the same tasks file as you used for RRA.
- Include actuator control constraints that define the control limits for each muscle (e.g., leg69_muscles_residuals_motor_control_limits.xml).
- Specify the same time range as before.
- Specify the output directory (e.g., <YourWorkingDirectory>\Stance\CMC).
- Under the Actuators and External Loads tab, select "Append to 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 that leg69_CMC_residuals_motors.xml is to be appended.
- Specify the external loads (same as for RRA).
- Save your CMC settings to a file.
- Run the tool.
Tips and tricks for CMC
- One common way for CMC to fail is when the tool is unable to find a set of muscle forces that can accurately reproduce the joint dynamics. Consider reducing the tracking weights until your run successfully completes. Make sure to re-run RRA and use the adjusted model output from the RRA Tool in CMC when you adjust the tasks.
- Check the troubleshooting tips at the bottom of the Getting Started with CMC page.
- Plot the muscle activation patterns from the states file in the CMC results directory. (Tip: When selecting quantities to plot, use the "Filter By Pattern" to help your search. For example, typing "act" will list only the activation signals.)
- Are the simulated activations for the vastus intermedius (vas_int_r.activation) and gastrocnemius medialis (med_gas_r.activation) close to what you would expect?
- Plot the CMC residual joint moments (hip_flexion_r_moment, knee_angle_r_moment, and ankle_angle_r_moment) as functions of time from the *Actuation_force.sto file.
- Are the moments substantial? Does the plot give you confidence in the predicted muscle forces?
- Plot the CMC residual actuator forces (i.e., MZ, FX, and FY) as functions of time.
How large are the residual joint moments and residual actuator forces predicted by CMC as a percentage of the body weight of the model? Note: Residuals less than 2% of body weight are considered acceptable.