|
| 1 | +# Euler-Lagrange Dynamics |
| 2 | + |
| 3 | +## Overview & Motivation |
| 4 | + |
| 5 | +The Euler-Lagrange equations provide a systematic way to derive the equations of motion for mechanical systems from energy principles. Instead of tracking forces on each body (as in Newton's method), they express dynamics in terms of *generalized coordinates* $q$ and the system's kinetic and potential energy. |
| 6 | + |
| 7 | +For a robotic manipulator or any articulated mechanism with $n$ degrees of freedom, the Euler-Lagrange formulation yields a compact matrix equation: |
| 8 | + |
| 9 | +$$M(q)\ddot{q} + C(q, \dot{q})\dot{q} + g(q) = \tau$$ |
| 10 | + |
| 11 | +Where: |
| 12 | +- $q \in \mathbb{R}^n$ — generalized coordinates (joint angles/positions) |
| 13 | +- $\dot{q}, \ddot{q}$ — generalized velocities and accelerations |
| 14 | +- $M(q) \in \mathbb{R}^{n \times n}$ — mass (inertia) matrix, symmetric positive definite |
| 15 | +- $C(q, \dot{q})\dot{q} \in \mathbb{R}^n$ — Coriolis and centrifugal terms |
| 16 | +- $g(q) \in \mathbb{R}^n$ — gravitational terms |
| 17 | +- $\tau \in \mathbb{R}^n$ — generalized forces/torques (inputs) |
| 18 | + |
| 19 | +This formulation supports two fundamental computations: |
| 20 | +- **Forward dynamics**: given torques $\tau$, compute accelerations $\ddot{q} = M^{-1}(\tau - C\dot{q} - g)$ |
| 21 | +- **Inverse dynamics**: given desired accelerations $\ddot{q}$, compute required torques $\tau = M\ddot{q} + C\dot{q} + g$ |
| 22 | + |
| 23 | +## Mathematical Theory |
| 24 | + |
| 25 | +### Prerequisites |
| 26 | + |
| 27 | +The **Lagrangian** of a system is defined as: |
| 28 | + |
| 29 | +$$\mathcal{L}(q, \dot{q}) = T(q, \dot{q}) - V(q)$$ |
| 30 | + |
| 31 | +where $T$ is kinetic energy and $V$ is potential energy. |
| 32 | + |
| 33 | +### Core Definitions |
| 34 | + |
| 35 | +The **Euler-Lagrange equation** for coordinate $q_i$ is: |
| 36 | + |
| 37 | +$$\frac{d}{dt}\frac{\partial \mathcal{L}}{\partial \dot{q}_i} - \frac{\partial \mathcal{L}}{\partial q_i} = \tau_i \quad \text{for } i = 1, \ldots, n$$ |
| 38 | + |
| 39 | +For a rigid-body system, kinetic energy takes the form: |
| 40 | + |
| 41 | +$$T = \frac{1}{2}\dot{q}^T M(q) \dot{q}$$ |
| 42 | + |
| 43 | +Applying the Euler-Lagrange equation to this quadratic form yields the standard manipulator equation: |
| 44 | + |
| 45 | +$$M(q)\ddot{q} + C(q, \dot{q})\dot{q} + g(q) = \tau$$ |
| 46 | + |
| 47 | +### Mass Matrix $M(q)$ |
| 48 | + |
| 49 | +The mass matrix is always **symmetric** ($M = M^T$) and **positive definite** ($\dot{q}^T M \dot{q} > 0$ for $\dot{q} \neq 0$). These properties guarantee: |
| 50 | +- The forward dynamics linear system $M\ddot{q} = f$ always has a unique solution |
| 51 | +- Physical kinetic energy is always non-negative |
| 52 | + |
| 53 | +### Coriolis Matrix $C(q, \dot{q})$ |
| 54 | + |
| 55 | +The Coriolis matrix captures velocity-dependent forces using **Christoffel symbols of the first kind**: |
| 56 | + |
| 57 | +$$c_{ij} = \sum_{k=1}^{n} \frac{1}{2}\left(\frac{\partial m_{ij}}{\partial q_k} + \frac{\partial m_{ik}}{\partial q_j} - \frac{\partial m_{jk}}{\partial q_i}\right)\dot{q}_k$$ |
| 58 | + |
| 59 | +A key property: $\dot{M} - 2C$ is skew-symmetric, which is important for passivity-based control. |
| 60 | + |
| 61 | +### Gravity Vector $g(q)$ |
| 62 | + |
| 63 | +$$g_i(q) = \frac{\partial V}{\partial q_i}$$ |
| 64 | + |
| 65 | +where $V(q)$ is the total potential energy of the system. |
| 66 | + |
| 67 | +## Complexity Analysis |
| 68 | + |
| 69 | +| Operation | Time | Space | Notes | |
| 70 | +|------------------|-----------------|----------|------------------------------------------------------| |
| 71 | +| Forward dynamics | $O(n^3)$ | $O(n^2)$ | Dominated by $M^{-1}$ solve via Gaussian elimination | |
| 72 | +| Inverse dynamics | $O(n^2)$ | $O(n^2)$ | Matrix-vector multiplication $M \ddot{q}$ | |
| 73 | +| Model evaluation | Model-dependent | $O(n^2)$ | Computing $M(q)$, $C(q,\dot{q})$, $g(q)$ | |
| 74 | + |
| 75 | +For systems with $n \leq 6$ DOF (typical robotic manipulators), the $O(n^3)$ cost of Gaussian elimination is negligible. For larger systems, consider the Recursive Newton-Euler Algorithm (RNEA) which achieves $O(n)$ inverse dynamics. |
| 76 | + |
| 77 | +## Step-by-Step Walkthrough |
| 78 | + |
| 79 | +### Example: Simple Pendulum (1-DOF) |
| 80 | + |
| 81 | +A point mass $m$ on a rigid rod of length $l$: |
| 82 | + |
| 83 | +**System parameters:** $m = 1\,\text{kg}$, $l = 1\,\text{m}$, $g_0 = 9.81\,\text{m/s}^2$ |
| 84 | + |
| 85 | +**Model matrices:** |
| 86 | +- $M(q) = ml^2 = 1.0$ |
| 87 | +- $C(q, \dot{q})\dot{q} = 0$ (single DOF → no Coriolis) |
| 88 | +- $g(q) = mgl\sin(q) = 9.81\sin(q)$ |
| 89 | + |
| 90 | +**Forward dynamics** at $q = 0.5\,\text{rad}$, $\dot{q} = 0$, $\tau = 0$: |
| 91 | + |
| 92 | +$$\ddot{q} = M^{-1}(\tau - C\dot{q} - g) = \frac{0 - 0 - 9.81\sin(0.5)}{1.0} = -4.703\,\text{rad/s}^2$$ |
| 93 | + |
| 94 | +**Inverse dynamics** for holding position ($\ddot{q} = 0$): |
| 95 | + |
| 96 | +$$\tau = M\ddot{q} + C\dot{q} + g = 0 + 0 + 9.81\sin(0.5) = 4.703\,\text{N·m}$$ |
| 97 | + |
| 98 | +### Example: Two-Link Planar Arm (2-DOF) |
| 99 | + |
| 100 | +For a 2-DOF arm with equal links ($m_1 = m_2 = 1\,\text{kg}$, $l_1 = l_2 = 1\,\text{m}$): |
| 101 | + |
| 102 | +**At rest** ($q = [0, 0]^T$, $\dot{q} = [0, 0]^T$): |
| 103 | +- $\sin(q_1) = 0$, $\sin(q_1 + q_2) = 0$ |
| 104 | +- $g = [0, 0]^T$ → gravity terms vanish when links hang vertically |
| 105 | +- Forward dynamics with $\tau = 0$ produces $\ddot{q} = [0, 0]^T$ (equilibrium) |
| 106 | + |
| 107 | +## Pitfalls & Edge Cases |
| 108 | + |
| 109 | +- **Singular mass matrix**: Should not happen for physically valid systems, but numerical conditioning degrades near kinematic singularities (e.g., fully extended arm). The Gaussian elimination solver uses partial pivoting to help. |
| 110 | +- **Fixed-point arithmetic**: Dynamics values (torques, accelerations) typically exceed the $[-1, 1)$ range of Q15/Q31 formats. Use `float` unless inputs are carefully scaled. |
| 111 | +- **Coriolis computation**: The choice of Coriolis parameterization (Christoffel vs. factored form) affects the skew-symmetry property of $\dot{M} - 2C$. The interface returns the product $C(q,\dot{q})\dot{q}$ directly, leaving the parameterization choice to the user. |
| 112 | +- **Energy consistency**: For simulation, ensure the model matrices satisfy the skew-symmetry property; otherwise, energy may not be conserved in numerical integration. |
| 113 | +- **Units**: Be explicit about whether angles are in radians (standard) and torques in N·m. |
| 114 | + |
| 115 | +## Variants & Generalizations |
| 116 | + |
| 117 | +| Variant | Trade-off | Use Case | |
| 118 | +|--------------------------------------|------------------------------------------|------------------------------------------------------| |
| 119 | +| **Euler-Lagrange** (this) | $O(n^3)$ forward, closed-form, intuitive | Small systems ($n \leq 6$), control design, analysis | |
| 120 | +| **Newton-Euler** | Body-by-body force balance | Single rigid bodies, intuitive for simple systems | |
| 121 | +| **Recursive Newton-Euler (RNEA)** | $O(n)$ inverse dynamics | Large kinematic chains, real-time control | |
| 122 | +| **Articulated Body Algorithm (ABA)** | $O(n)$ forward dynamics | Large chains, simulation | |
| 123 | +| **Hamiltonian formulation** | Phase-space, symplectic integration | Long-horizon simulation, energy preservation | |
| 124 | + |
| 125 | +## Applications |
| 126 | + |
| 127 | +- **Robot control**: Computed torque control, gravity compensation, impedance control |
| 128 | +- **Simulation**: Forward dynamics integration for physics simulation |
| 129 | +- **System identification**: Estimate dynamic parameters from measured motion |
| 130 | +- **Trajectory optimization**: Inverse dynamics as constraints in optimization |
| 131 | +- **Vibration analysis**: Linearized dynamics around equilibrium points |
| 132 | + |
| 133 | +## Connections to Other Algorithms |
| 134 | + |
| 135 | +- **Gaussian Elimination** ([GaussianElimination.md](../solvers/GaussianElimination.md)): Used internally to solve $M\ddot{q} = f$ in forward dynamics |
| 136 | +- **LQR Controller** ([Lqr.md](../controllers/Lqr.md)): Euler-Lagrange dynamics can be linearized to produce the $(A, B)$ state-space matrices needed for LQR design |
| 137 | +- **Kalman Filter** (../filters/active/): State estimation for partially observed dynamical systems derived from Euler-Lagrange models |
| 138 | +- **DARE** ([DiscreteAlgebraicRiccatiEquation.md](../solvers/DiscreteAlgebraicRiccatiEquation.md)): Discretized Euler-Lagrange systems feed into DARE for optimal control gain computation |
| 139 | + |
| 140 | +## References & Further Reading |
| 141 | + |
| 142 | +- Siciliano, B., Sciavicco, L., Villani, L., & Oriolo, G. (2009). *Robotics: Modelling, Planning and Control*. Springer. Chapters 7–8. |
| 143 | +- Spong, M. W., Hutchinson, S., & Vidyasagar, M. (2020). *Robot Modeling and Control* (2nd ed.). Wiley. Chapter 6. |
| 144 | +- Murray, R. M., Li, Z., & Sastry, S. S. (1994). *A Mathematical Introduction to Robotic Manipulation*. CRC Press. |
| 145 | +- Featherstone, R. (2008). *Rigid Body Dynamics Algorithms*. Springer. (For RNEA and ABA extensions.) |
0 commit comments