Control of hybrid dynamics with application to a hopping robot