Algorithm Search⌘K

Problemcore

Forward dynamics

Also called direct dynamics.

Given the state q, q' of a robot and its joint torques tau, find the joint accelerations q'' = M(q)^-1 (tau - C q' - g). Solved in O(n) by the articulated-body algorithm.

Forward dynamics is the problem of finding how a robot accelerates: given its joint positions qq, joint velocities q˙\dot q and joint torques τ\tau, find the joint accelerations q¨\ddot q. For a robot without contact the answer is unique, q¨=M(q)−1(τ−C(q,q˙)q˙−g(q))\ddot q = M(q)^{-1}\big(\tau - C(q, \dot q)\dot q - g(q)\big). Simulation of a robot is forward dynamics inside an ODE integrator. This page states the problem and its bounds; the articulated-body algorithm page gives the O(n)O(n) method in detail, and inverse dynamics is the opposite problem.

In plain words

You know where every joint of a robot is, how fast it moves, and which torque each motor gives. What happens next? Forward dynamics answers with the acceleration of every joint. One motor torque moves the whole arm, because the links push on each other, so the answer is a coupled system of equations, one per joint. A simulator asks this question many times per second and steps the state forward with the answer.

Definition

Input:

  • A robot model: nn joints, each revolute or prismatic, joined into a serial chain or a tree with a fixed base; the joint axes and the link frames; and for each link its mass, center of mass and rotational inertia.
  • The gravity vector, (0,0,−9.81)(0, 0, -9.81) m/s2^2 in the space frame {s}\{s\}.
  • The state (q,q˙)∈Rn×Rn(q, \dot q) \in \mathbb{R}^n \times \mathbb{R}^n, the joint torques τ∈Rn\tau \in \mathbb{R}^n, and optionally external wrenches FextF_{\text{ext}} on given links with their Jacobians J(q)J(q).

Output: the vector q¨∈Rn\ddot q \in \mathbb{R}^n that satisfies the manipulator equation

M(q)q¨+C(q,q˙)q˙+g(q)=τ+J(q)TFext.M(q)\ddot q + C(q, \dot q)\dot q + g(q) = \tau + J(q)^T F_{\text{ext}}.

Because the joint-space inertia matrix M(q)M(q) is symmetric positive definite, the output exists and is unique:

q¨=M(q)−1(τ+J(q)TFext−C(q,q˙)q˙−g(q)).\ddot q = M(q)^{-1}\big(\tau + J(q)^T F_{\text{ext}} - C(q, \dot q)\dot q - g(q)\big).

The simulation version adds an initial state (q(0),q˙(0))(q(0), \dot q(0)) and a torque history τ(t)\tau(t) on [0,T][0, T], and asks for q(t)q(t). It is the ODE initial value problem x˙=f(x,τ(t))\dot x = f(x, \tau(t)) with x=(q,q˙)x = (q, \dot q), and each evaluation of ff is one forward dynamics problem.

Variants

  • Floating base. A legged robot, a humanoid or a space robot has six extra coordinates for its base, which no motor drives directly. The problem has the same form with n+6n + 6 unknowns; see floating-base dynamics.
  • Closed loops. Parallel robots and four-bar linkages add loop-closure constraints A(q)q¨=b(q,q˙)A(q)\ddot q = b(q, \dot q) with unknown multipliers λ\lambda. The problem becomes the linear system [MATA0][q¨−λ]=[τ−Cq˙−gb]\begin{bmatrix} M & A^T \\ A & 0\end{bmatrix}\begin{bmatrix}\ddot q \\ -\lambda\end{bmatrix} = \begin{bmatrix}\tau - C\dot q - g \\ b\end{bmatrix}. The Gauss principle of least constraint gives the same solution as the minimizer of a quadratic program.
  • Contact with friction. Unilateral contacts and Coulomb friction turn the problem into a complementarity problem, which may have no solution or several (the Painleve paradox). Simulators usually solve it at the velocity level with a time step; see rigid contact complementarity and Stewart-Trinkle time stepping.
  • Hybrid dynamics. Some joints have a given acceleration and the rest a given torque. The unknowns are the accelerations of the second set and the torques of the first.
  • Derivatives. Optimal control and estimation need ∂q¨/∂q\partial\ddot q/\partial q, ∂q¨/∂q˙\partial\ddot q/\partial\dot q and ∂q¨/∂τ=M−1\partial\ddot q/\partial\tau = M^{-1}; see rigid-body dynamics derivatives.

Examples

Take the planar 2R arm with L1=L2=1L_1 = L_2 = 1 m and point masses of 1 kg at the link ends, in a vertical plane, with q1q_1 measured from the horizontal. Its terms are M=[[3+2c2,1+c2],[1+c2,1]]M = [[3 + 2c_2, 1 + c_2], [1 + c_2, 1]], Cq˙=(−s2(2q˙1q˙2+q˙22), s2q˙12)C\dot q = (-s_2(2\dot q_1\dot q_2 + \dot q_2^2),\ s_2\dot q_1^2) and g=9.81(2c1+c12, c12)g = 9.81(2c_1 + c_{12},\ c_{12}), where c2=cos⁡q2c_2 = \cos q_2, s2=sin⁡q2s_2 = \sin q_2, c1=cos⁡q1c_1 = \cos q_1 and c12=cos⁡(q1+q2)c_{12} = \cos(q_1 + q_2).

Free fall. At q=(0,0)q = (0, 0), at rest, with τ=0\tau = 0: M=[[5,2],[2,1]]M = [[5, 2], [2, 1]], M−1=[[1,−2],[−2,5]]M^{-1} = [[1, -2], [-2, 5]] and g=(29.43,9.81)g = (29.43, 9.81) N m. So q¨=−M−1g=(−29.43+19.62, 58.86−49.05)=(−9.81,9.81)\ddot q = -M^{-1}g = (-29.43 + 19.62,\ 58.86 - 49.05) = (-9.81, 9.81) rad/s2^2. Both masses fall with 9.819.81 m/s2^2 at the first instant, and link 2 keeps its absolute angle because q¨1+q¨2=0\ddot q_1 + \ddot q_2 = 0.

Motion without gravity. At q=(0,π/2)q = (0, \pi/2), q˙=(1,1)\dot q = (1, 1) rad/s and τ=0\tau = 0, in a horizontal plane: M=[[3,1],[1,1]]M = [[3, 1], [1, 1]] with det⁡M=2\det M = 2, and Cq˙=(−3,1)C\dot q = (-3, 1) N m. So q¨=−M−1(−3,1)=−12(1⋅(−3)−1⋅1, −1⋅(−3)+3⋅1)=(2,−3)\ddot q = -M^{-1}(-3, 1) = -\tfrac12(1 \cdot (-3) - 1 \cdot 1,\ -1 \cdot (-3) + 3 \cdot 1) = (2, -3) rad/s2^2. The inverse dynamics of this state and acceleration gives back M(2,−3)+(−3,1)=(3,−1)+(−3,1)=(0,0)M(2, -3) + (-3, 1) = (3, -1) + (-3, 1) = (0, 0).

Conditioning. At q2=0q_2 = 0 the eigenvalues of MM are 3±223 \pm 2\sqrt2, so its condition number is (3+22)2≈34(3 + 2\sqrt2)^2 \approx 34. Arms with heavy proximal links and light distal links have much larger condition numbers, which makes the solve for q¨\ddot q sensitive to errors in τ\tau and in the model.

Known algorithms

All counts are in the real-RAM model for a serial chain or a tree of nn joints with one degree of freedom each.

  1. Inverse dynamics plus a linear solve (Walker and Orin 1982, their first method). One call of the recursive Newton-Euler algorithm with q¨=0\ddot q = 0 gives the bias h=Cq˙+gh = C\dot q + g. Calls with q˙=0\dot q = 0, no gravity and q¨=ej\ddot q = e_j give the columns of MM. That is n+1n + 1 calls of an O(n)O(n) algorithm, so O(n2)O(n^2) to form the system, and then O(n3)O(n^3) to solve Mq¨=τ−hM\ddot q = \tau - h.
  2. Composite-rigid-body method (Walker and Orin 1982, their third method; Featherstone 2008, Chapter 6). The bias comes from one RNEA call, and the composite-rigid-body algorithm forms MM in O(n2)O(n^2) for a serial chain. A Cholesky decomposition M=LLTM = LL^T costs O(n3)O(n^3), and the two triangular solves O(n2)O(n^2). For trees, the factorization can keep the branch-induced sparsity of MM and costs less.
  3. Articulated-body algorithm (Featherstone 1983; Featherstone 2008, Chapter 7). It never forms MM. A pass from the base outward computes the velocities, a pass inward computes the articulated-body inertia and bias force of each subtree, and a second pass outward computes the accelerations. Each pass does a constant amount of work per joint, so the total is O(n)O(n).
  4. Lynch and Park (Section 8.5) state the problem with MM and hh from their closed-form expressions and solve the linear system, which is the second method in matrix notation.

Which method is fastest in practice depends on nn and on the branching. For small nn the composite-rigid-body method is often faster than the articulated-body algorithm, because its constants are smaller; Featherstone (2008, Chapter 10) compares the operation counts. Do not use a hand count as a published one.

Bounds

  • Upper bound: O(n)O(n) arithmetic operations for a serial chain or a tree, by the articulated-body algorithm.
  • Upper bound with MM: O(n2)O(n^2) to form MM plus O(n3)O(n^3) for the dense Cholesky factorization of a serial chain. The cubic term counts the factorization; without it, given a factor, the solve is O(n2)O(n^2).
  • Lower bound: Ω(n)\Omega(n), because the output has nn numbers and in general each depends on the input. So forward dynamics of a serial chain or a tree is Θ(n)\Theta(n) in the real-RAM model.

Reductions

  • Forward dynamics to inverse dynamics. Because the manipulator equation is affine in q¨\ddot q, n+1n + 1 calls of an inverse dynamics routine give MM and hh, and one solve gives q¨\ddot q. This is method 1 above.
  • Inverse dynamics to forward dynamics. The map τ↦q¨\tau \mapsto \ddot q is affine, q¨=M−1τ+b\ddot q = M^{-1}\tau + b. With n+1n + 1 calls of a forward dynamics routine you get bb (at τ=0\tau = 0) and the columns of M−1M^{-1} (at τ=ej\tau = e_j), and then τ=M(q¨−b)\tau = M(\ddot q - b). So the two problems are equivalent up to O(n)O(n) calls and an O(n3)O(n^3) solve, although direct algorithms solve each in O(n)O(n).
  • Simulation to forward dynamics. An explicit Runge-Kutta method of order 4 makes four forward dynamics calls per time step. For long runs without friction, symplectic integrators are used because their energy error does not drift. Since MM depends on qq, the Hamiltonian is not separable, and the usual symplectic methods for it are implicit.

Applications

  • Robot simulators and physics engines evaluate forward dynamics at every time step, often with contact.
  • Shooting methods for trajectory optimization roll out the dynamics from a guess of the torques.
  • Model-based state estimators predict the next state with forward dynamics.
  • Control design checks a controller in simulation, with a model that differs on purpose from the one inside the controller.

References

  1. Kevin M. Lynch and Frank C. Park, Modern Robotics, Mechanics, Planning, and Control, Cambridge University Press, 2017, Chapter 8, Section 8.5 (forward dynamics of open chains)
  2. Roy Featherstone, Rigid Body Dynamics Algorithms, Springer, 2008, Chapter 6 (the composite-rigid-body algorithm and the factorization of the joint-space inertia matrix), Chapter 7 (forward dynamics, the articulated-body algorithm) and Chapter 10 (accuracy and efficiency)
  3. M. W. Walker and D. E. Orin, Efficient dynamic computer simulation of robotic mechanisms, Journal of Dynamic Systems, Measurement, and Control 104(3), 205-211, 1982, the whole paper (forward dynamics by repeated inverse dynamics calls, and the composite-rigid-body method)
  4. Roy Featherstone, The calculation of robot dynamics using articulated-body inertias, International Journal of Robotics Research 2(1), 13-30, 1983, the whole paper (the articulated-body algorithm, linear in the number of joints)
  5. Bruno Siciliano, Lorenzo Sciavicco, Luigi Villani and Giuseppe Oriolo, Robotics, Modelling, Planning and Control, Springer, 2009, Chapter 7 (direct dynamics and inverse dynamics)

Where this leads

About this page

The build computes these levels from the evidence in the repository. Each row says what the next level needs. Read what the levels mean.

LadderLevelWhat the next level needs
Human proofH0 no proof
  • add a proof in proofs/ (06.5)
LeanL0 no Lean part
  • name a Lean module in the lean field (07)
VisualV0 none
  • add viz/scene.ts or a figure (10)
WritingW2 basic
  • a known algorithm
  • a contract.yaml