Locomotion generation for quadruped robots on challenging terrains via quadratic programming