Closed Loop Control Algorithm for Obstacle Avoidance Based on the Transformation of Master and Slave Tasks