Robot dynamics: separate the torques that move an arm

Explore robot dynamics through a two-link arm's torque budget. Separate inertia, velocity coupling, gravity, and friction, then check holding torque, link mass, and mechanical power.

By 13 min read

What you will learn

  • Identify the four torque contributions in a manipulator equation.
  • Explain why one joint's acceleration can require torque at another joint.
  • Calculate gravity compensation with an explicit sign convention.
  • Connect a positive definite mass matrix to kinetic energy.
  • Check mechanical power against energy change and damping loss.

Before you start

A horizontal robot arm can need substantial torque while it sits still. With two one-meter rods weighing one kilogram each, our model needs 19.62 N m at the shoulder and 4.905 N m at the elbow just to hold its pose.

Robot dynamics explains those torques and how they change during motion. This lesson separates inertia, velocity coupling, gravity, and friction, then checks the result through mechanical power.

A stationary arm can need torque

Imagine holding a long board horizontally with one hand. Gravity pulls down at its center of mass, creating a turning moment about your hand. Supporting that moment requires torque even when the board's velocity and acceleration are zero.

A robot joint faces the same calculation. Moving the arm introduces additional requirements: accelerating mass, maintaining curved motion, and overcoming joint friction.

Forward kinematics tells us where the arm sits for given joint angles. Dynamics adds mass and forces to explain which torques can support or change that motion.

Define the arm and its coordinates

The example uses two rigid, uniform slender rods in a vertical plane. A fixed shoulder supports link 1, and an elbow connects link 2.

  • Both links have length 1 m and a center of mass 0.5 m from their proximal joint.
  • Link 1 has mass 1 kg. Link 2 starts at 1 kg, with a control from 0.5 to 2 kg.
  • Each rod's moment of inertia about its center is I = mL²/12. Changing link 2's mass changes its inertia too.
  • Gravity points downward, along world −y. Its magnitude is 9.81 m/s² unless you turn it off.

Let q₁ measure the shoulder angle counterclockwise from world +x. Let q₂ measure the elbow angle relative to link 1. Link 2's absolute orientation is q₁ + q₂, so its absolute angular velocity is q̇₁ + q̇₂.

The equations use radians. The angle sliders show degrees and convert them before calculation. Positive actuator torques correspond to increasing their joint coordinates; the elbow actuator acts between the two links.

The model has no payload, tip force, gearing, motor inertia, joint springs, or contact constraints. The mass control changes the entire second rod, preserving its uniform distribution. DFKI's double-pendulum documentation shows a broader parameter set; its coordinate and inertia conventions differ from this example.

Read the robot dynamics equation

For this fully actuated arm with zero external force:

τ = M(q) q̈ + c(q, q̇) + g(q) + f(q̇)

Each vector has one entry per joint. The Lagrangian formulation in Modern Robotics derives this structure from kinetic and potential energy.

TermWhat it contributesUnits here
M q̈Torque associated with joint accelerationN m
cTorque from products of joint velocitiesN m
gTorque that balances gravity at this poseN m
fTorque that offsets joint frictionN m

The mass matrix M uses kg m² for these rotational coordinates. Joint velocity uses rad/s and acceleration uses rad/s², with radians treated as dimensionless in the SI torque calculation.

This equation answers an inverse-dynamics question: which torques produce a specified acceleration at the current position and velocity? Forward dynamics uses the same equation to find acceleration from supplied torques.

Account for inertia and joint coupling

With the fixed lengths and first-link mass above, let m denote the numerical value of link 2's mass in kilograms. The mass-matrix entries below then have units kg m²:

M₁₁ = 1/3 + 4m/3 + m cos q₂
M₁₂ = M₂₁ = m/3 + (m/2) cos q₂
M₂₂ = m/3

At full extension with m = 1, the rows are (8/3, 5/6) and (5/6, 1/3). If only the elbow accelerates at 1 rad/s², the inertial torque vector is the second column: (5/6, 1/3) N m. The shoulder needs torque even though its own acceleration is zero.

That coupling comes from the connected links. Elbow motion changes forces that pass through the shoulder. Off-diagonal entries need not stay positive: folding the elbow to 180° makes M₁₂ = −1/6 for this mass.

The matrix remains symmetric positive definite. For every nonzero joint-velocity vector v, vᵀMv is positive, giving positive kinetic energy. Positive definite describes the quadratic form, not the sign of every entry.

For this model, the numerical determinant is m/9 + m²(1/3 − cos²q₂/4). Its lower bound is m/9 + m²/12, which is positive for every allowed mass. Full extension may make a tip Jacobian singular, while M remains invertible.

Include the velocity-product terms

Even constant joint velocities can accelerate a link's center of mass along a curved path. Define h = (m/2) sin q₂ using the same substituted SI geometry:

c₁ = −h (2q̇₁q̇₂ + q̇₂²)
c₂ = h q̇₁²

The mixed product contributes a Coriolis term; squared speeds contribute centripetal terms. Setting q̈ = 0 removes M q̈, but it can leave c nonzero. Setting both joint velocities to zero removes c.

You may also see c = C(q, q̇) q̇. Different C matrices can produce the same velocity-product vector. MIT's manipulator-equation notes explain that nonuniqueness; this lab displays c directly.

For q₂ = −60° and q̇ = (1, −0.5) rad/s, h = −√3/4. The resulting c is approximately (−0.324760, −0.433013) N m. These signed terms subtract from the total actuator torque at that instant.

Check the sign of gravity compensation

Let γ be the positive gravitational acceleration magnitude. The compensation vector is the gradient of gravitational potential energy:

g₁ = (0.5 + m)γ cos q₁ + 0.5mγ cos(q₁ + q₂)
g₂ = 0.5mγ cos(q₁ + q₂)

Gravity itself applies generalized torque −g. Our equation places +g on the compensation side, so a stationary hold needs τ = g. Check which side of an equation a source uses before comparing signs.

With both rods horizontal to the right, their centers sit 0.5 m and 1.5 m from the shoulder. Their gravitational moments add to 9.81 × (0.5 + 1.5) = 19.62 N m. Only link 2's 0.5 m moment arm contributes to the elbow hold: 4.905 N m.

Rotate the straight arm to face left and both hold torques change sign. Point it vertically upward or downward and the ideal gravitational joint moments vanish. Zero torque at the upright pose does not establish stable balance under a disturbance.

Account for joint damping

The lab uses the same nonnegative viscous coefficient B at both joints:

f = (Bq̇₁, Bq̇₂)
P_loss = B(q̇₁² + q̇₂²)

B has units N m s/rad. The physical damping torque opposes each joint's velocity, so the actuator adds +Bq̇ to compensate. The compensation torque can be negative, while its dissipated power stays nonnegative.

For B = 0.25 and q̇ = (1, −0.5), f = (0.25, −0.125) N m. Damping removes 0.3125 W of mechanical energy. This simple model omits static friction, Coulomb friction, and changing lubrication effects.

The friction models lesson compares viscous, Coulomb, and Stribeck behavior. It also treats static friction as a range of holding torques at zero velocity, where the simple Bq̇ term always vanishes.

Inspect one instant of arm motion

Read the torque terms at one instant

What must each joint contribute?

Set a pose, joint velocities, and accelerations. The model adds inertia, velocity coupling, gravity, and joint friction to find actuator torques.

0.00
0.00
0.00
0.00
0.00
0.00
1.00
0.00

Both rods are 1 m long. Link 1 has mass 1 kg; link 2 keeps its uniform mass distribution as its mass changes. The shoulder angle starts from world +x, and the elbow angle is relative to link 1. Positive angles and torques turn counterclockwise.

Arm pose in the vertical plane

Two-link arm at shoulder 0 degrees and relative elbow 0 degreesBlue is link 1; brown is link 2. Small open circles show their centers of mass. World y points upward. Required shoulder torque is 19.620000 newton meters and elbow torque is 4.905000 newton meters. The picture shows a single instant, with no simulated motion.-2-20022x (m)y (m)
Square: fixed shoulder. Filled circle: elbow. Open circles: centers of mass. Both plot axes use the same scale. The drawing allows links to overlap; collision geometry is outside this model.
Actuator torque contributions (N m)
TermShoulderElbow
Inertia0.0000000.000000
Velocity coupling0.0000000.000000
Gravity19.6200004.905000
Friction0.0000000.000000
Total19.6200004.905000
Mass matrix M (kg m²)
RowColumn 1Column 2
12.6666670.833333
20.8333330.333333

Each torque row contributes to the signed total. Negative entries subtract. The mass matrix remains symmetric and positive definite for every allowed pose and link mass.

Shoulder torque (N m)
19.620000
Elbow torque (N m)
4.905000
Kinetic energy (J)
0.000000
Potential energy (J)
0.000000
Actuator power (W)
0.000000
Damping loss (W)
0.000000
Mechanical energy rate (W)
0.000000
Power balance residual (W)
0.000000
Mass determinant (kg² m⁴)
0.194444

Actuator power 0.000000 W equals mechanical energy rate 0.000000 W plus damping loss 0.000000 W, up to floating-point rounding.

This is one prescribed instant with zero external force. Potential energy uses zero height at the shoulder and may be negative. Actuator power is mechanical joint power; holding torque can consume electrical power even when joint velocity is zero.

The initial Horizontal hold reproduces the two gravity torques. The experiment inspects a prescribed instant; it does not integrate a trajectory. Choosing velocities and accelerations changes the torque calculation without animating the arm.

  • Bent and moving sets q = (30°, −60°), q̇ = (1, −0.5), and q̈ = (0.5, −1), with damping 0.25. The shoulder total is 17.416659 N m and the elbow total is 3.648175 N m.
  • Elbow acceleration turns gravity off and sets q̈ = (0, 1) with zero angles and velocities. Only inertial torque remains: (0.833333, 0.333333) N m.
  • Zero gravity hold sets all motion values to zero with gravity off. Every torque term becomes zero, while the mass matrix still describes the arm's inertia.

The torque table shows signed contributions. For Bent and moving, the shoulder adds 0.500000 − 0.324760 + 16.991418 + 0.250000. Small differences when adding the displayed values come from rounding.

Presets replace all controls with their stated values. Reset returns to Horizontal hold. The drawing shows centers of mass and permits link overlap; the model omits self-collision, obstacles, actuator limits, and structural flexibility.

Connect torques to energy and power

The kinetic and gravitational potential energies are:

T = ½ q̇ᵀ M(q) q̇
V = (0.5 + m)γ sin q₁ + 0.5mγ sin(q₁ + q₂)

Both use joules. V uses zero height at the shoulder, so it can be negative. Adding a constant to V changes no torque because its gradient stays the same.

For fixed model parameters and no external force, the energy balance is:

d(T + V)/dt = τᵀq̇ − B(q̇₁² + q̇₂²)

The dot product τᵀq̇ gives signed mechanical actuator power in watts. A negative value means the actuators absorb mechanical power at that instant. Electrical consumption also depends on motors and drives, which this model omits.

Because M changes with the elbow angle, differentiating T includes ½ q̇ᵀṀq̇ as well as q̇ᵀM q̈. The velocity-product vector satisfies q̇ᵀc = ½ q̇ᵀṀq̇. Omitting that term would spoil the power check.

Bent and moving has T = 0.833333 J and V = 4.905000 J. Its actuator power is 15.592571 W, mechanical energy rate is 15.280071 W, and damping loss is 0.312500 W. The displayed residual subtracts the last two from actuator power and should read zero up to rounding.

A stationary horizontal hold has nonzero torque but zero mechanical power, since q̇ = 0. Its motors may still draw current and generate heat. A mass-slider change creates a different model; the power identity describes time evolution with that model's mass held constant.

Reproduce the torque budget in Python

This Python 3 example uses only the standard library. It evaluates the same uniform-rod model, including the configuration derivative needed for the power check.

from math import sin, cos, radians


def budget(angles, velocity, acceleration, mass=1, gravity=9.81, damping=0):
    q1, q2 = map(radians, angles)
    v1, v2 = velocity
    a1, a2 = acceleration
    M11 = 1/3 + 4*mass/3 + mass*cos(q2)
    M12 = mass/3 + mass*cos(q2)/2
    M22 = mass/3
    h = mass*sin(q2)/2
    inertia = (M11*a1 + M12*a2, M12*a1 + M22*a2)
    coupling = (-h*(2*v1*v2 + v2*v2), h*v1*v1)
    g2 = mass*gravity*cos(q1+q2)/2
    weight = ((0.5+mass)*gravity*cos(q1) + g2, g2)
    friction = (damping*v1, damping*v2)
    torque = tuple(sum(terms) for terms in zip(inertia, coupling, weight, friction))
    kinetic = (M11*v1*v1 + 2*M12*v1*v2 + M22*v2*v2)/2
    potential = (0.5+mass)*gravity*sin(q1) + mass*gravity*sin(q1+q2)/2
    Mdot11 = -mass*sin(q2)*v2
    energy_rate = (v1*inertia[0] + v2*inertia[1]
                   + Mdot11*(v1*v1 + v1*v2)/2
                   + v1*weight[0] + v2*weight[1])
    power = torque[0]*v1 + torque[1]*v2
    loss = damping*(v1*v1 + v2*v2)
    return torque, kinetic, potential, power, energy_rate, loss


for name, args, damping in [
    ("Hold", ((0, 0), (0, 0), (0, 0)), 0),
    ("Bent", ((30, -60), (1, -0.5), (0.5, -1)), 0.25),
]:
    torque, T, V, power, rate, loss = budget(*args, damping=damping)
    print(f"{name} torque: ({torque[0]:.6f}, {torque[1]:.6f}) N m")
    print(f"{name} energy: T={T:.6f} J; V={V:.6f} J")
    print(f"{name} power: actuator={power:.6f} W; rate={rate:.6f} W; loss={loss:.6f} W")

Expected output:

Hold torque: (19.620000, 4.905000) N m
Hold energy: T=0.000000 J; V=0.000000 J
Hold power: actuator=0.000000 W; rate=0.000000 W; loss=0.000000 W
Bent torque: (17.416659, 3.648175) N m
Bent energy: T=0.833333 J; V=4.905000 J
Bent power: actuator=15.592571 W; rate=15.280071 W; loss=0.312500 W

Try it yourself

Exercise 1. Make the second rod heavier. Start at Horizontal hold and change link 2's mass to 2 kg. Calculate both holding torques. Which moment arms explain the increase?

Check the heavier-link calculation

The shoulder supports 1 kg at 0.5 m and 2 kg at 1.5 m. Its torque is 9.81 × (0.5 + 3) = 34.335 N m. The elbow supports the 2 kg rod at 0.5 m, requiring 9.81 N m.

The increases are 14.715 N m and 4.905 N m. Link 2's center stays in the same location, and its rotational inertia doubles. A tip payload would use a different center location and inertia model.

Exercise 2. Accelerate only the elbow. Turn gravity off, keep both links horizontal with mass 1 kg each, and set both velocities to zero. Request q̈ = (0, 1) rad/s². Find both torques and the instantaneous mechanical power.

Check the coupled acceleration

Multiply M by (0, 1) to select its second column. The required torques are (5/6, 1/3) N m, approximately (0.833333, 0.333333). The Elbow acceleration preset reproduces this case.

Both joint velocities are zero at that instant, so τᵀq̇ = 0 W. Acceleration can be nonzero while instantaneous power is zero; as velocity changes, the subsequent power can change. A zero shoulder torque would generally fail to produce the requested zero shoulder acceleration.

Sources and further study

Continue with inverse dynamics to calculate torques for a prescribed motion and a tip force. Then use forward dynamics to see how the arm accelerates when you supply the torques.