A synergetic theory of quadrupedal gaits and gait transitions