A Simple Algorithm For Designing Control Systems And Its Applications In Robotics