SUMMARYThe equations of motion of a controlled mechanical system subject to holonomic constraints may be formulated in terms of the states and controls by applying a constrained version of the Lagrange-d'Alembert principle. This paper derives a structure-preserving scheme for the optimal control of such systems using, as one of the key ingredients, a discrete analogue of that principle. This property is inherited when the system is reduced to its minimal dimension by the discrete null space method. Together with initial and final conditions on the configuration and conjugate momentum, the reduced discrete equations serve as nonlinear equality constraints for the minimization of a given objective functional. The algorithm yields a sequence of discrete configurations together with a sequence of actuating forces, optimally guiding the system from the initial to the desired final state. In particular, for the optimal control of multibody systems, a force formulation consistent with the joint constraints is introduced. This enables one to prove the consistency of the evolution of momentum maps. Using a two-link pendulum, the method is compared with existing methods. Further, it is applied to a satellite reorientation maneuver and a biomotion problem.