Physical Dynamics and Constraints › Rigid-Body Dynamics

Michael BrenndoerferJune 20, 20267 min read
World Models HandbookAll chapters
Part 4 of 12Space, Physics, and Causality
Chapter 20Physical Dynamics and Constraints › Rigid-Body Dynamics
Reading section 3 of 12 · Rigid-Body Dynamics · 7 minSection 3 of 12 · 7 min

Book contents

Section 3 of 12 · 7 min read

Physical Dynamics and Constraints › Rigid-Body DynamicsOne section · Sections in this chapter3 / 12 ↓
Reading tools Definitions & inline links

Choose your expertise level to adjust how many terms are explained. Beginners see more tooltips, experts see fewer to maintain reading flow. Hover over underlined terms for instant definitions.

Article links

Make inline references clickable

Rigid-body dynamics describes objects whose shape does not change, so their configuration reduces to a finite set of coordinates. It is the workhorse of robotics and game physics, and it is the cleanest setting in which to see what "structure" means for a learned model. Most of the ideas in this chapter, energy functions, generalized coordinates, constraints, symplectic updates, are easiest to state for rigid bodies and then generalize, so we will spend some care here.

Generalized Coordinates and the Lagrangian

Recall from Part I, Chapter 6 that we described general dynamical systems as state-space models x˙=f(x,u)\dot{x}=f(x,u). For rigid bodies, the art is choosing the state. Here, generalized coordinates q=(q1,…,qn)q=(q_1,\dots,q_n) mean an independent local set of numbers that pins down the configuration. For an ideal open-chain arm, independent joint angles within a valid chart remove the link-length constraints that Cartesian joint positions would require. Closed kinematic loops and global orientation descriptions can still require constraints or multiple coordinate charts.

Given coordinates qq and velocities q˙\dot{q}, a regular conservative mechanical system can encode its mechanical core in a single scalar function, the Lagrangian:

L(q,q˙)=T(q,q˙)−V(q),\mathcal{L}(q, \dot{q}) = T(q, \dot{q}) - V(q),

where:

  • T(q,q˙)T(q, \dot{q}): the kinetic energy, the energy of motion
  • V(q)V(q): the potential energy, the energy stored in the configuration by gravity, springs, and other conservative fields
  • L\mathcal{L}: the Lagrangian, here kinetic energy minus potential energy; nonconservative forces, impacts, and active constraints require additional terms or equations

For a regular conservative Lagrangian system, masses, lengths, and conservative couplings enter through TT and VV. Actuation, dissipation, impacts, and time-dependent constraints require additional generalized forces or equations. The equations of motion follow from the Euler–Lagrange equation:

ddt∂L∂q˙i−∂L∂qi=τi,\frac{d}{dt}\frac{\partial \mathcal{L}}{\partial \dot{q}_i} - \frac{\partial \mathcal{L}}{\partial q_i} = \tau_i,

where:

  • qiq_i, q˙i\dot{q}_i: the ii-th generalized coordinate and its velocity
  • ∂L∂q˙i\frac{\partial \mathcal{L}}{\partial \dot{q}_i}: the conjugate momentum for coordinate ii, how the Lagrangian responds to velocity
  • ddt∂L∂q˙i\frac{d}{dt}\frac{\partial \mathcal{L}}{\partial \dot{q}_i}: the rate of change of that momentum along the trajectory
  • ∂L∂qi\frac{\partial \mathcal{L}}{\partial q_i}: the position derivative of the Lagrangian, which contributes to the generalized-force balance
  • τi\tau_i: the generalized force or torque applied externally at coordinate ii

In words, the equation balances the change in conjugate momentum against the Lagrangian's position dependence and the applied generalized force. When τi=0\tau_i=0, it gives p˙i=∂L/∂qi\dot p_i=\partial\mathcal{L}/\partial q_i; pip_i is conserved only when qiq_i is a cyclic coordinate, or more generally when the corresponding continuous symmetry holds. A regular learned Lagrangian, whose velocity Hessian is nonsingular, induces a structured vector field through differentiation. That reduces the learned output from a 2n2n-component vector field to one scalar, but nonconservative forces and constraints remain separate modeling choices.

The Hamiltonian Formulation

For a regular Lagrangian, define the conjugate momenta pi=∂L/∂q˙ip_i = \partial \mathcal{L} / \partial \dot{q}_i and the Hamiltonian H(q,p)=p⊤q˙−L\mathcal{H}(q, p) = p^\top \dot{q} - \mathcal{L}. For the autonomous natural systems used here, it equals total mechanical energy; that identification is not universal. The dynamics become first-order and symmetric:

q˙=∂H∂p,p˙=−∂H∂q+τ.\dot{q} = \frac{\partial \mathcal{H}}{\partial p}, \qquad \dot{p} = -\frac{\partial \mathcal{H}}{\partial q} + \tau.

where τ\tau collects externally applied generalized forces and torques. When τ=0\tau=0, the canonical Hamiltonian flow preserves phase-space volume. Hamiltonian neural architectures build directly on this antisymmetric form. Position changes along the momentum gradient and momentum changes against the position gradient, making H˙=0\dot{\mathcal H}=0 for an autonomous unforced system. Arbitrary dissipative or state-dependent forcing can break both energy conservation and volume preservation.

Why does this matter for world models? Suppose you train an autonomous neural scalar Hθ(q,p)\mathcal{H}_\theta(q, p) from observed trajectories. Computing ∂Hθ/∂p\partial \mathcal{H}_\theta / \partial p and −∂Hθ/∂q-\partial \mathcal{H}_\theta / \partial q with autodiff gives a conservative Hamiltonian vector field for every setting of the weights. Its exact continuous flow conserves the learned scalar Hθ\mathcal{H}_\theta. Whether that scalar matches physical energy, and whether a discrete numerical rollout preserves it accurately, remain empirical questions. This is the idea behind Hamiltonian Neural Networks (Greydanus, Dzamba, and Yosinski, 2019) and Lagrangian Neural Networks (Cranmer et al., 2020), and we will implement a Hamiltonian model in the worked example. A regular autonomous Lagrangian network has an analogous learned energy conservation law. The Lagrangian variant is useful when you observe positions and velocities but not momenta, since it fits L(q,q˙)\mathcal{L}(q, \dot{q}) directly and avoids the change of variables.

Newton–Euler and Multibody Systems

The Lagrangian view is elegant but not the only one. The Newton–Euler formulation works directly with forces and torques on each body: ∑F=ma\sum F = m a for translation and, in a body-fixed frame about the center of mass, ∑τ=Iω˙+ω×Iω\sum \tau = I \dot{\omega} + \omega \times I \omega for rotation. Here II is the constant body-frame inertia tensor and ω\omega is angular velocity. The cross-product term ω×Iω\omega \times I\omega produces gyroscopic effects such as precession. Chaining bodies together with joints yields the recursive algorithms used in real-time robot dynamics. Given the robot's masses, link lengths, and inertias, the multibody equations take the form

M(q)q¨+C(q,q˙)q˙+g(q)=τ,M(q)\ddot{q} + C(q, \dot{q})\dot{q} + g(q) = \tau,

where:

  • M(q)M(q): the symmetric positive-definite mass matrix, which maps generalized accelerations to the forces they require
  • q¨\ddot{q}: the vector of generalized accelerations
  • C(q,q˙)q˙C(q, \dot{q})\dot{q}: the Coriolis and centrifugal forces, the velocity-dependent terms that arise as parts of the body rotate
  • g(q)g(q): the generalized gravity torques, the joint forces gravity induces at configuration qq
  • τ\tau: the vector of applied joint forces or torques

Each term has a clean physical identity, and that identity is exploitable. For independent coordinates in a regular mechanical system, M(q)M(q) is symmetric positive-definite because kinetic energy is 12q˙⊤M(q)q˙\tfrac{1}{2}\dot{q}^\top M(q)\dot{q}. The gravity term is the gradient of a potential, g(q)=∂V(q)/∂qg(q)=\partial V(q)/\partial q. These are checkable properties: losing positive definiteness makes the kinetic-energy model nonphysical and can make the acceleration solve ill-posed or unstable.

This is a classical system-identification target from Part II, Chapter 3: within a correctly specified, identifiable rigid-body model, estimating the inertial parameters determines its dynamics. Friction, compliance, actuator dynamics, and other mismatch remain outside that parameter set. The structured form therefore tells you which parameters to estimate and where a residual model may be needed. Inertial parameters enter linearly in common inverse-dynamics regressions, which can make that part of identification a convex least-squares problem.

What the Model Predicts Versus What the Agent Does

It is easy to conflate two different uses of a dynamics model. The model predicts states; the agent uses predictions to choose actions. Rigid-body structure serves both, but differently:

  • For prediction, valid structure can improve long-horizon fidelity. Under the regularity and step-size conditions described below, symplectic integration can keep energy error bounded over many steps even while phase error accumulates.
  • For control, selected structure can improve tractability. The control-affine multibody form supports inverse dynamics and computed-torque control; model predictive control can use quadratic programs after suitable linearization or convexification.

The distinction matters because a model can be good at one use and poor at the other. A model with excellent prediction but no convenient control structure may be harder to optimize inside a planning loop, while a tractable model with poor rollout fidelity can mislead a long-horizon plan. A differentiable or queryable black-box transition model can still support control, but mechanical structure often provides more useful optimization form and more specific invariants to test.