Dynamic legged locomotion through trajectory optimization and reinforcement learning