Collision Detection in Legged Locomotion Using Supervised Learning