Gaits and energetics in terrestrial legged locomotion