The equations of motion for a robot manipulator and its relationship to the Euler-Lagrange equation is well known and extremely useful in robotics, and yet I couldn’t find a single source that provides the derivation–I suppose it’s one of those “the solution is trivial and is left as an exercise to the reader” situations. Well, I’m providing one here for dummies like me who need it spelled out step-by-step.

$$$$\frac{d}{dt}\biggl[\frac{\partial L}{\partial\dot{q}}\biggr] - \frac{\partial L}{\partial q} = 0$$$$

Now we add a non-conservative generalized force $\tau$, which can represent damping or input torque.

$$$$\frac{d}{dt}\biggl[\frac{\partial L}{\partial\dot{q}}\biggr] - \frac{\partial L}{\partial q} = \tau$$$$

Recall that the Lagrangian $L$ is a function of the vector of generalized coordinates $q(t)$, its time derivative $\dot{q}(t)$, and time $t$. We typically hide this function notation to keep the equations pretty, but it’s important to recognize so that we can perform differential calculus on it.

$$$$L = L(q(t), \dot{q}(t), t)$$$$

Recall also that the Lagrangian is equal to the sum of the kinetic and potential energy terms.

$$$$L = T - U$$$$

Taking the partial derivative of that with respect to $q$, we get:

$$$$\frac{\partial L}{\partial q} = \frac{\partial T}{\partial q} - \frac{\partial U}{\partial q}$$$$

This we can plug back into equation 2:

$$$$\frac{d}{dt}\biggl[\frac{\partial L}{\partial\dot{q}}\biggr] - \frac{\partial T}{\partial q} + \frac{\partial U}{\partial q} = \tau$$$$

As for the first term, we can use the chain rule to expand it:

$$$$\frac{d}{dt}\biggl[\frac{\partial L}{\partial\dot{q}}\biggr] = \biggl[\frac{\partial^2 L}{\partial\dot{q}^2}\biggr] \ddot{q} + \biggl[\frac{\partial^2 L}{\partial q \partial\dot{q}}\biggr]\dot{q} + \frac{\partial}{\partial t} \biggl[\frac{\partial L}{\partial \dot{q}}\biggr]$$$$

Plugging equation 7 back into equation 6, we get:

$$$$\underbrace{\biggl[\frac{\partial^2 L}{\partial\dot{q}^2}\biggr]}_{M} \ddot{q} + \underbrace{\biggl[\frac{\partial^2 L}{\partial q \partial\dot{q}}\biggr]\dot{q} - \frac{\partial T}{\partial q}}_C + \underbrace{\frac{\partial U}{\partial q}}_G + \underbrace{\frac{\partial}{\partial t} \biggl[\frac{\partial L}{\partial \dot{q}}\biggr]}_{\text{time-varying term}}= \tau$$$$

We can ignore the time derivative term for a time-invariant system (a safe assumption for most robotic manipulators).

$$$$\underbrace{\biggl[\frac{\partial^2 L}{\partial\dot{q}^2}\biggr]}_{M} \ddot{q} + \underbrace{\biggl[\frac{\partial^2 L}{\partial q \partial\dot{q}}\biggr]\dot{q} - \frac{\partial T}{\partial q}}_C + \underbrace{\frac{\partial U}{\partial q}}_G = \tau$$$$ $$$$M(q)\ddot{q} + C(q, \dot{q}) + G(q) = \tau$$$$