A Direct Method for Solving Nonsmooth Optimal Control Problems