Analytical Derivatives of Rigid Body Dynamics Algorithms

Justin Carpentier, Nicolas Mansard

Abstract: Rigid body dynamics is a well-established framework in robotics. It can be used to expose the analytic form of kinematic and dynamic functions of the robot model. So far, two major algorithms, namely the recursive Newton-Euler algorithm (RNEA) and the articulated body algorithm (ABA), have been proposed to compute the inverse dynamics and the forward dynamics in a few microseconds. Evaluating their derivatives is an important challenge for various robotic applications (optimal control, estimation, co-design or reinforcement learning). However it remains time consuming, whether using finite differences or automatic differentiation. In this paper, we propose new algorithms to efficiently compute them thanks to closed-form formulations. Using the chain rule and adequate algebraic differentiation of spatial algebra, we firstly differentiate explicitly RNEA. Then, using properties about the derivative of function composition, we show that the same algorithm can also be used to compute the derivatives of ABA with a marginal additional cost. For this purpose, we introduce a new algorithm to compute the inverse of the joint-space inertia matrix, without explicitly computing the matrix itself. All the algorithms are implemented in our open-source C++ framework called Pinocchio. Benchmarks show computational costs varying between 3 microseconds (for a 7-dof arm) up to 17 microseconds (for a 36-dof humanoid), outperforming the alternative approaches of the state of the art.

Introduction

In modern robotics, computational speed is a critical factor. Whether a humanoid robot is balancing on uneven terrain or a robotic arm is performing high-speed assembly, the underlying "brain" must solve complex optimization problems in real-time. A significant bottleneck in these calculations is computing derivatives—determining how a robot's motion changes in response to small adjustments in joint positions, velocities, or torques.

To control a robot effectively, one must master its dynamics. Forward dynamics (calculated via the Articulated Body Algorithm, or ABA) predicts motion given specific torques, while inverse dynamics (calculated via the Recursive Newton-Euler Algorithm, or RNEA) determines the torques required for a specific motion. While these base algorithms are fast, modern control techniques like Model Predictive Control (MPC) require their derivatives. Historically, researchers relied on slow finite differences or heavy automatic differentiation, which can consume up to 90% of total computation time. This paper introduces a breakthrough: lightning-fast analytical formulas for these derivatives.

Methods: A First-Principles Approach

Rather than relying on software-based differentiation, the authors utilize a mathematical approach grounded in spatial algebra. Spatial algebra combines linear and angular quantities into 6D vectors, keeping expressions concise and exploiting the inherent sparsity of a robot's kinematic tree.

Spatial representation of a rigid body and its connection within a kinematic tree.

Differentiating RNEA and the Reciprocity Trick

The authors apply the chain rule directly to the recursive steps of the Newton-Euler algorithm. A key innovation is the "reciprocity trick": instead of a separate, complex derivation for forward dynamics (ABA), they recognize that forward dynamics is the functional inverse of inverse dynamics. By differentiating the identity relationship between the two, they demonstrate that ABA derivatives can be calculated directly from RNEA derivatives using the inverse of the joint-space inertia matrix ($M^{-1}$).

To facilitate this, they introduce a new three-pass algorithm to compute $M^{-1}$ without ever explicitly building the full, dense inertia matrix $M$. This ensures the computation scales linearly with the number of joints. These algorithms are implemented in Pinocchio, an open-source C++ framework.

Key Results and Benchmarks

The approach was evaluated using three standard robot models: the 7-DOF KUKA-LWR arm, the 18-DOF HyQ quadruped, and the 36-DOF Atlas humanoid. The analytical results were compared against finite differences and state-of-the-art automatic differentiation.

Computational benchmarks comparing the proposed analytical derivatives against finite differences and alternative methods for various robot models.
  • Blazing Speed: Analytical derivatives for a 7-DOF arm take just 3 microseconds. Even for the complex 36-DOF Atlas humanoid, the process takes only 17 microseconds.
  • Massive Speedup: Compared to finite differences, the analytical approach is 7 to 26 times faster.
  • Superior Accuracy: Unlike finite differences, which suffer from numerical noise and rounding errors, the analytical method is numerically exact.
  • Efficiency: The derivatives are only about 3 times slower than computing the dynamics themselves—a remarkably low overhead that makes high-frequency whole-body MPC feasible.

Conclusion

By moving from numerical approximations to closed-form analytical derivatives, this work removes a major computational barrier in robotics. The resulting speedups allow for more sophisticated control and optimization loops, potentially enabling humanoids to operate at frequencies higher than 100Hz. Future work may extend these methods to derivatives with respect to model parameters, such as limb mass or length, facilitating the simultaneous optimization of a robot's physical design and its controller.

Summary updated

Abstract

Rigid body dynamics is a well-established frame--work in robotics. It can be used to expose the analytic form of kinematic and dynamic functions of the robot model. So far, two major algorithms, namely the recursive Newton-Euler algorithm (RNEA) and the articulated body algorithm (ABA), have been proposed to compute the inverse dynamics and the forward dynamics in a few microseconds. Evaluating their derivatives is an important challenge for various robotic applications (optimal control, estimation, co-design or reinforcement learning). However it remains time consuming, whether using finite differences or automatic differentiation. In this paper, we propose new algorithms to efficiently compute them thanks to closed-form formulations. Using the chain rule and adequate algebraic differentiation of spatial algebra, we firstly differentiate explicitly RNEA. Then, using properties about the derivative of function composition, we show that the same algorithm can also be used to compute the derivatives of ABA with a marginal additional cost. For this purpose, we introduce a new algorithm to compute the inverse of the joint-space inertia matrix, without explicitly computing the matrix itself. All the algorithms are implemented in our open-source C++ framework called Pinocchio. Benchmarks show computational costs varying between 3 microseconds (for a 7-dof arm) up to 17 microseconds (for a 36-dof humanoid), outperforming the alternative approaches of the state of the art.
BibTeX
@inproceedings{carpentier2018analytical,
  author = {Justin Carpentier and Nicolas Mansard},
  title = {{Analytical Derivatives of Rigid Body Dynamics Algorithms}},
  booktitle = {Robotics: Science and Systems},
  year = {2018},
  doi = {10.15607/rss.2018.xiv.038},
}
Figure