Intelligent obstacle avoidance