Model-based motion optimization for quadruped robots with an actuated articulated torso