# Character Physics with Inverse Dynamics

*The following blog post, unless otherwise noted, was written by a member of Gamasutra’s community.*

The thoughts and opinions expressed are those of the writer and not Gamasutra or its parent company.The thoughts and opinions expressed are those of the writer and not Gamasutra or its parent company.

**Overview of Inverse Dynamics**

Are you interested in the physics behind a humanoid character or perhaps some other animal? Then you might want to know the forces and torques required to move an arm or leg from one position to another position. Inverse Dynamics computes the forces and torques of an articulated body. This is traditionally very useful in robotics, since you need to know the joint torques required to rotate a link from one point in space to another. In animation, this helps to create a physically realistic response from the character.

Every character has an articulated body of links and joints. If you already know the orientations of each joint, along with the angular velocity and angular acceleration at each joint, then you are well prepared to leverage Inverse Dynamics. If you do not know the angles and you perhaps only know the Cartesian coordinates of the end effector, then you might want to leverage Inverse Kinematics to compute the angles needed for Inverse Dynamics. Additionally, this Overview of Inverse Kinematics should help on the vocabulary we’re going to use for this discussion.

**What is Inverse Kinematics?**

So what’s the difference between Inverse Dynamics and Inverse Kinematics? Many engineers have heard of Inverse Kinematics, but less have heard of Inverse Dynamics. This article gives an Overview of Inverse Dynamics. Inverse Kinematics deals with just the motion. Inverse Dynamics however, deals with forces and torques required for a desired motion. You can think of Inverse Kinematics as a function with inputs of Cartesian coordinates and outputs of Orientations required to reach those Cartesian Coordinates. In other words, what do the joint angles need to be in order for an articulated body to reach a Cartesian coordinate? Inverse Dynamics, on the other hand, is a function that takes joint orientations (and their time derivatives) as inputs and joint torques and forces as outputs. Not only does Inverse Dynamics give you the joint torques required to make a certain rotation, but it also gives you the forces and torques from the link.

If you’re interested in an in depth discussion of Inverse Kinematics, see Overview of Inverse Kinematics.

**What is Forward Dynamics?**

If there is Inverse Dynamics, then what is Forward Dynamics? Inverse dynamics relies on the motion of the subject and a body model to compute the forces that were necessary to produce this movement. Inverse Dynamics is used much more often than Forward Dynamics as a type of biomechanical modeling. Forward Dynamics uses joint torques/forces to predict resultant motions. In other words, if you know the torques/forces of an articulated body, then Forward Dynamics helps you predict the orientations of each link in the articulated body.

**What are the uses of Inverse Dynamics?**

There are many uses of Inverse Dynamics. The traditional use case of inverse dynamics in robotics, is to compute the joint forces/torques necessary to move a robot arm from one Cartesian coordinate to another. You cannot merely ask the robot to move to a point in space without specifying the forces/torques necessary to move the robot with the desired kinematic motion. However, this essential requirement in robotics is not as important in simulations or animations, because you can merely move a point from one point to another without having to abide by the laws of physics.

In addition to computing forces to realize a desired kinematic motion, Inverse Dynamics also helps compute the forces when external forces are involved. Inverse Dynamics can help compute the internal forces for a humanoid picking something up, or carrying something. A humanoid can pickup/carry a box, a briefcase, a backpack, and more. Inverse Dynamics can even help articulated bodies to react to external forces, such as a getting hit by a projectile. Additionally, external ground forces need to be kept in mind when an articulated body is walking on the floor. Even leaning on a wall causes normal forces. Inverse Dynamics can take into account all of these external forces.

**Motion Data**

Inverse Dynamics requires kinematic data to compute the forces. Luckily, we can derive the inverse dynamics from motion capture data which can be found in the Unity Store or the Carnegie Mellon MoCap Database. Additionally, if you are involving external forces then you also need kinetic data. Traditionally, ground forces for gait analysis are captured through force plates. However, you can also estimate kinetic data through mass and motion data (F = ma).

**Closed Loop Problem**

There is a potential issue with inverse dynamics though when the articulated body has a closed loop. A closed loop occurs during walking when both feet are in contact with the ground. At this point, the lower limbs form a loop with the supporting plane. A closed loop also occurs when multiple fingers are grasping an object. The difficulty in handling closed loops comes from indeterminacy. For example, if an object is held with both hands, inverse dynamics cannot determine the joint force and torque along an arm from the given motion alone. Some counteracting forces can exist without being detected in the kinematic profile of the motion itself. The indeterminacy is not caused by our selection of the dynamic computation methodology. Rather, it is a generic property of the inverse dynamics problem itself.

There are workarounds to this issue. For example, for biped locomotion, you can adopt a simple approximate solution. The ground force can be distributed to each foot according to the percentage of body support on each leg. If a percent of the upper body weight is supported by the left leg and the remaining percent is supported by the right leg, then the left hip gets a percent of the force and torque from the pelvis and the right hip gets the remaining percent. (This can be judged by computing the center of mass).

This has been an Overview of Inverse Dynamics, including use cases. Confused by the jargon? See an Overview of Inverse Kinematics.

Looking for an implementation? See Create Your Own Inverse Dynamics in Unity.