I am working on sub-Riemannian geometry and try to understand what are the tools to find the equations of a sub-Riemannian problem. Here is an example: Let us consider the system defined by a lagrangian: \begin{equation} L=\frac{1}{2}m(\overset{\cdot}{x}^2+\overset{\cdot}{y}^2)+\frac{1}{2}I\overset{\cdot}{\theta}^2 \end{equation} And take the following non-holonomic constraint \begin{equation} \mathscr{D}=span\left\{\cos\theta\frac{\partial}{\partial x}+\sin\theta\frac{\partial}{\partial y},\frac{\partial}{\partial\theta}\right\} \end{equation} So we have, \begin{equation} \mathscr{D}^\perp=span\{\omega\} \end{equation} with $\omega=-\sin\theta dx+\cos\theta dy$ If I understand clearly the sub-Riemannian problem is to minimize \begin{equation} \int_0^TLdt \end{equation} under the constaint $\dot{z}(t)\in\mathscr{D}(z(t))$. Now, how do I find these equations? So far I am not asking how to solve these equations but just to understand how to find them in the first place. Thanks in advance for your help.