Learning-based control for a legged robot