Optimal control theory allows finding the optimal input of a mechanical system modelled as a initial value problem. The resulting minimisation problem may be solved with known direct and indirect methods. We here propose time discretisations for both methods, direct midpoint (DMP) and indirect midpoint (IMP) algorithms, which despite their similarities result in different convergence orders for the adjoint (or co-state) variables. We additionally propose a third time-integration scheme, Indirect Hamiltonian Preserving (IHP) algorithm, which preserves the control Hamiltonian, an integral of the analytical Euler-Lagrange equations of the optimal control problem.We test the resulting algorithms to linear and non-linear problems with and without dissipative forces: a propelled falling mass subjected to gravity and a drag force, an elastic inverted pendulum, and the locomotion of a worm-like organism on a frictional substrate. In order to improve the convergence of the solution process of the discretised equations in non-linear problems, we also propose a computational simple suboptimal initial guess, and apply a forwardbackward sweep method, which computes each set of variables (state, adjoint and control) in a staggered manner. We demonstrate in our examples their practical advantage for computing optimal solutions.