System And Method For Controlling A Robot