Minimizing Energy Consumption Leads to the Emergence of Gaits in Legged Robots