Robotic Systems

Robotic Systems · teaching-draft · v0.2.0

Recursive inverse dynamics and the mass matrix

Lecture 7 · Week 4 · 90 minutes

Learning outcomes

  • Explain the two passes of RNEA.
  • Relate inverse dynamics to columns of M.
  • Query engine dynamics without confusing algorithms and APIs.

Prerequisites: Linear algebra, ODEs, and earlier lectures in this sequence.

Recursive Newton–Euler algorithm

A tree-structured robot permits local computations along its links. RNEA first propagates spatial velocity and acceleration from parent to child. A backward pass accumulates inertial and external wrenches from children to parents. Projecting each link wrench onto its joint motion subspace gives the required generalized force.

In a conventional spatial notation, a link velocity has the form Vi=XiVλ(i)+SiviV_i=X_iV_{\lambda(i)}+S_iv_i. Acceleration adds the joint acceleration and a velocity-product term. These spatial vectors require a consistent component order, reference point, and frame. They are not automatically arranged like MuJoCo's free-joint qvel.

For a fixed-base tree with bounded joint size, inverse dynamics can be computed in linear time in the number of bodies. Contact constraints and actuator allocation are separate problems.

Mass matrix through inverse dynamics

For ideal unconstrained dynamics, inverse dynamics returns M(q)a+c(q,v)M(q)a+c(q,v). Evaluate at a fixed state with zero acceleration to obtain the bias. Repeating with unit acceleration eje_j gives

M:j=ID⁡(q,v,ej)−ID⁡(q,v,0).M_{:j}=\operatorname{ID}(q,v,e_j)-\operatorname{ID}(q,v,0).
This is a useful conceptual and testing construction, but repeating inverse dynamics for every column costs more than one RNEA call.

CRBA builds composite subtree inertias and uses them to assemble the joint-space mass matrix. Its purpose differs from RNEA: CRBA supplies M, while RNEA supplies force for a requested acceleration.

Worked column test

For M=[5221]M=\begin{bmatrix}5&2\\2&1\end{bmatrix} and c=(3,4)c=(3,4), zero-acceleration inverse dynamics gives (3,4)(3,4). Unit acceleration in joint 1 gives (8,6)(8,6). Their difference is (5,2)(5,2), the first column. Forgetting to subtract the bias corrupts every inferred column.

MuJoCo and Pinocchio

Practice 4 compares dense M with finite differences of MuJoCo inverse dynamics on a contact-free arm, at a fixed state. Passive force terms cancel in the difference when independent of the requested acceleration. It also checks the full force balance.

MuJoCo exposes functions such as mj_rne and mj_crb, while its high-level inverse call also handles engine-specific forces and constraints. Pinocchio exposes algorithms named rnea and crba directly. Do not label every call to mj_inverse as a bare textbook RNEA calculation MuJoCo API Pinocchio algorithms.

Exercise

Why do column differences become unreliable if each call uses a different q? Answer: M changes with configuration, so the result no longer isolates a linear map from acceleration to force at one state. Freeze q, v, contacts, and model parameters for the test.

A good dynamics API exercise tests numerical identities and documents conventions, rather than judging correctness from a robot animation.

Reading and source connections

Advanced Robot Dynamics and Simulation — lecture series — CMU 16-715. Companion video series for modeling, integration, rigid-body dynamics, constraints, and contact.

Pinocchio documentation — Stack of Tasks / Pinocchio contributors. Optional independent implementation of RNEA, CRBA, and ABA for an engine comparison.

MuJoCo API functions — MuJoCo contributors. Function-level reference. The lockfile fixes the executable version; stable documentation can move.