A theory of metabolic costs for bipedal gaits