# Module 4.4: Rigid-Body Equations of Motion

- Course: [Course 4: Feedback Control & Robot Dynamics](https://roboticsconcepts.dev/courses/feedback-control-robot-dynamics.md)
- HTML Page: https://roboticsconcepts.dev/courses/feedback-control-robot-dynamics/rigid-body-equations-of-motion/
- Key Concepts: M(q)q̈ + C(q,q̇)q̇ + g(q) = τ, Configuration-dependent inertia, Coriolis & centrifugal coupling

Once a robot has two or more joints swinging together, each joint stops living in its own tidy bubble. Bending your elbow changes how heavy your shoulder feels; spinning your waist flings your outstretched hand outward. The rigid-body manipulator equation looks intimidating at first glance, yet every single symbol in it corresponds to a physical push you can feel yourself.

## Reading M(q)q̈ + C(q,q̇)q̇ + g(q) = τ in plain English

Think of this famous equation as an accountant's ledger for joint torque τ. On the right side is the torque your motors actually deliver. On the left side are the three physical jobs that torque has to pay for:

- M(q)q̈ — Inertia torque: accelerating the links. Notice M depends on q (the pose)! When an elbow stretches straight out, the shoulder's effective inertia M₁₁ spikes compared to when the elbow is tucked tight against the chest.
- C(q,q̇)q̇ — Velocity coupling (Coriolis & centrifugal): forces that appear only when joints are already moving (q̇ ≠ 0). Spin around on an office chair and pull your arms inward: as inertia drops, you speed up — that's the same coupling.
- g(q) — Gravity torque: the static load required just to keep the links from falling at the current pose q, even when velocity and acceleration are zero.

## Why M(q) changes mid-reach

When you tuck a heavy dumbbell tight against your shoulder, swinging your upper arm left and right feels quick and snappy. Extend your elbow straight out, and suddenly your shoulder has to move that same weight on a much longer radius.

Even on a 1-link arm, sliding a motor or payload closer to vs. farther from the shoulder changes M(q) dramatically. On a multi-link arm, bending the elbow literally moves the forearm's mass closer to or farther from the shoulder axis in real time.

## Interactive Sandbox: Mass & Rotational Inertia Slider Lab

Use the Inertia & Swing Lab below as a concrete single-joint slice of M(q)q̈ = τ: treat the motor distance slider as your arm's effective reach r(q) changing as outer joints fold or extend, and watch how the required acceleration torque τ = I·α shifts while payload mass stays fixed.

## Forward dynamics vs. inverse dynamics

Depending on which side of the equals sign you already know, the exact same equation runs in two opposite directions:

In inverse dynamics, you have a desired trajectory (q, q̇, q̈) and plug it into the left-hand side to solve immediately for the motor torques τ needed to pull it off. In forward dynamics — what physics engines like MuJoCo or Isaac Sim run at every timestep — you know the motor torques τ, invert M(q), and solve for the resulting joint accelerations q̈ to step the simulation forward.

## The manipulator equation of motion

```text
M(q) q̈  +  C(q, q̇) q̇  +  g(q)  =  τ
```

Total motor torque τ pays for accelerating pose-dependent inertia M(q)q̈, handling moving-frame centrifugal/Coriolis forces C(q,q̇)q̇, and holding up gravity g(q).

## Check Your Intuition

**Question:** A robot arm is holding completely still (q̇ = 0 and q̈ = 0) straight out to the side. Which terms in M(q)q̈ + C(q,q̇)q̇ + g(q) = τ are nonzero?

- [ ] Only M(q)q̈, because mass never disappears
- [✓] Only g(q), because velocity and acceleration are both zero
- [ ] Both C(q,q̇)q̇ and g(q), because the arm is stretched out

**Explanation:** When q̇ = 0 and q̈ = 0, both the inertial acceleration term M(q)q̈ and the velocity coupling term C(q,q̇)q̇ vanish completely, leaving τ = g(q) to balance gravity.

## Where You'll See This in Modern Robotics

Fast C++ rigid-body libraries like Pinocchio and MuJoCo compute inverse dynamics (RNEA) and forward dynamics (ABA) in microseconds, letting whole-body controllers and RL environments evaluate full multi-joint physics inside tight control loops.

## Companion Python Notebook: 04 · Manipulator Dynamics: M(q), C(q,q̇) & g(q)

Evaluate each term of the 2-link manipulator equations of motion and visualize how shoulder inertia changes as the elbow bends.

- Open in molab (WASM): https://molab.marimo.io/github/alchemicduncan/robotics-concepts-dev/blob/main/notebooks/course-4/04_rigid_body_equations_of_motion.py/wasm
- Open in Google Colab: https://colab.research.google.com/github/alchemicduncan/robotics-concepts-dev/blob/main/notebooks/colab/course-4/04_rigid_body_equations_of_motion.ipynb
- Download .py: https://roboticsconcepts.dev/downloads/notebooks/course-4/04_rigid_body_equations_of_motion.py
- Download .ipynb: https://roboticsconcepts.dev/downloads/notebooks/colab/course-4/04_rigid_body_equations_of_motion.ipynb
- Run locally: `uvx marimo edit --sandbox notebooks/course-4/04_rigid_body_equations_of_motion.py`
