A Terradynamics of Legged Locomotion on Granular Media