Path Planning and Obstacles Avoidance using Switching Potential Functions