Algorithm to Prevent Obstacle Collision