Implementation of receding horizon control using a variational integrator.