Adjoint-based Optimal Control Design for a Cart Pendulum System with Dry Friction