Consider the following system: I derived the equations of motion for a basic pendulum using the following Lagrangian:
$$\begin{align} L & = T - V\\ &= \frac{1}{2} m \ell^2 \dot{\theta}^2 + mg\ell\cos(\theta) \\ \end{align}$$
So the Euler Lagrange equations are $$\begin{align} \frac{d}{dt}\left(\frac{\partial L}{\partial \dot{\theta}}\right)-\frac{\partial L}{\partial \theta} &= 0\\ m\ell^2\ddot{\theta}-(-mg\ell \sin(\theta))&=0\\ \ell\ddot{\theta}+g\sin(\theta)&=0 \end{align} $$
However, I want to consider a system where the pendulum could hit the ground and the ground would impede any further motion. How would I go about incorporating that into the Lagrangian?
Obviously, once it hits the ground, it stops moving anywhere. Could I add some kind of constraint angle on $\theta$? But how would I include that in my Lagrangian?