Beginning of the obstacle avoidance code