The topics covered in this section include:

# Overview

Residual reduction is a form of forward dynamics simulation that uses a tracking controller to follow model kinematics determined from the inverse kinematics. Computed muscle control (CMC) serves as the controller, but without muscles the skeleton of the model can be used to determine a mass distribution and joint kinematics that are more consistent with ground reaction forces.

Residual reduction is primarily intended for gait, i.e., movements like walking and running where the model is displaced relative to the ground while subject to ground reaction forces and torques. In this chapter, we describe an example gait model (gait2354_simbody.osim) consisting of ten rigid segments (bones) where 17 of the 23 generalized coordinates (degrees of freedom) of the model represent angles for the joints connecting the rigid segments together. Each of these 17 degrees of freedom is actuated by a single torque actuator.

The remaining 6 generalized coordinates represent the 6 degrees of freedom (3 translational, 3 rotational) between the model's pelvis and the ground. To simulate walking, we need some way of representing how the model propels itself forward relative to the ground. One way would be to use a foot-ground contact mechanism.

Instead, we present a simpler solution: represent the 6 degrees of freedom between the pelvis and the ground as a 6-degree-of-freedom joint between the pelvis and the ground, and actuate each degree of freedom with its own torque actuator. Each of these 6 actuators is called a *residual* *actuator*. Now our model has 23 degrees of freedom and 23 actuators, i.e., exactly one actuator per degree of freedom. The three residuals that actuate the 3 translational degrees of freedom between the pelvis and the ground are the *residual forces*, whose values we denote by \(
F_x\), \(
F_y\), and *\(
F_z\)*. The 3 rotational degrees of freedom are actuated by the *residual torques* (or *moments*), whose values we denote by *\(
M_x\)*, \(
M_y\), and *\(
M_z\)*. \(
F_x\) is the force applied along the X (forward) axis, \(
F_y\) is the force applied along the Y (vertical) axis, *\(
M_x\)* is the torque applied about the X (forward axis), and so on.

Typically, modeling assumptions (e.g., having a model with no arms), noise, and other errors from motion capture data lead to *dynamic inconsistency*; essentially, the ground reaction forces and acceleration estimated from measured marker kinematics for a subject do not satisfy Newton's Second Law,

\[ F = ma.\] |

Roughly speaking, the 6 residuals amount to adding a new force to the equation that accounts for inconsistency:

\[ F + F_{\mathrm{residual}} = ma\] |

# Residual Reduction Algorithm (RRA)

## Tracking Simulation

RRA begins by placing the model in the starting configuration, i.e., by setting the values of the model's generalized coordinates to the values computed by the inverse kinematics (IK) tool for the user-specified initial time (specified in the setup file as the <initial_time> property). Repeatedly, RRA takes small steps forward in time (with each time step of .001) until the user-specified final time (specified under the <final_time> property of the setup file) is reached. In each step, force values are computed for all of the model's actuators to make the model move from its current configuration to the configuration (generalized coordinates) desired at the end of the step, which is computed from the IK output. The actuator forces are computed by choosing force and torque values that minimize an objective function (see Settings Files and XML Tag Definitions on Optimization Parameters).

## Mass Center Adjustment

At the end of the simulation, the average value for each residual actuator is computed. The average values for *\(
M_x\)* (the left-right residual torque) and \(
M_z\) (the fore-aft residual torque) are used to adjust the torso mass center to correct excessive "leaning" of the model due to inaccuracies in the mass distribution and geometry of the torso in the model. A new model file containing the adjusted torso mass center (specified in the setup file under the <output_model_file> property) is created.

## Mass Adjustment Recommendation

The average value of *\(
F_y\)* is used to compute the recommended mass changes for all of the body segments. The desired mass change is:

\[ F_y\,/g\] |

where *g* = -9.80665 m/s^{2}. This mass change is then divided up proportionally among the body segments. The computed mass changes are recommended to the user, who can make these changes in the OpenSim model file by hand. The recommended mass changes are NOT applied to the model automatically.

## Adjusted Kinematics

The same tracking simulation process is then repeated with three important differences:

- The model with the adjusted torso mass center is used
- The residuals are weighted more heavily to make the optimizer choose smaller values for the residuals when minimizing the objective function
- minimum and maximum limits are placed on the residual values

The goal of these restrictions on the residual values is to reduce the need for residuals to the absolute minimum that is necessary to closely follow the desired kinematics so that the motion is generated purely by internal joint moments. During computed muscle control (CMC), the next stage of OpenSim, the moments will be generated by forces exerted by muscles. This way, biomechanical results about muscle function concluded from CMC will be closer to reality than if we let the residuals be arbitrarily large.

With these restrictions placed on the residuals, the model's motion will likely be altered since the residuals may not be allowed to reach the magnitudes that would result from inverse dynamics while following the kinematics from IK exactly. If the minimum and/or maximum allowed residual values are too restrictive, the motion will be altered so dramatically that the results of RRA cannot be used to generate a realistic simulation with CMC. If the residual minimum and/or maximum values are too lenient, then the residuals will still be large enough to exert forces that might normally be exerted by muscles, and thus the results would lead to unrealistic muscle function from CMC.