Design and implementation of a self-righting single-legged robot