  In this paper, we describe a constrained Lagrangian and Hamiltonian formalism
for the optimal control of nonholonomic mechanical systems. In particular, we
aim to minimize a cost functional, given initial and final conditions where the
controlled dynamics is given by nonholonomic mechanical system. In our paper,
the controlled equations are derived using a basis of vector fields adapted to
the nonholonomic distribution and the Riemannian metric determined by the
kinetic energy. Given a cost function, the optimal control problem is
understood as a constrained problem or equivalently, under some mild regularity
conditions, as a Hamiltonian problem on the cotangent bundle of the
nonholonomic distribution. A suitable Lagrangian submanifold is also shown to
lead to the correct dynamics. We demonstrate our techniques in several examples
including a continuously variable transmission problem and motion planning for
obstacle avoidance problems.
