A computer-implemented method for guiding a vehicle from a source (S,302) to a target (T,304) within a scenario with obstacles, the method comprising the steps of: a) - establishing the source (S,302) as a starting point (S'); b) - computing a subpath from the starting point (S') to the target (T,304); c) detecting if an obstacle crosses the computed subpath; d) - computing a plurality of subpaths avoiding the detected obstacle (O,510,520), each subpath connecting the starting point (S') to a waypoint (W) of an outer boundary of the detected obstacle (O,510,520); e) - detecting if a further obstacle crosses each of the plurality of subpaths; f) -repeating the steps d) - e) for each further obstacle; g) computing a priority value for each waypoint (W), wherein the priority value is computed based on: the distance between the waypoint (W) and the target (T,304) regardless of eventual obstacles located between the waypoint (W) and the target (T,304), and the accumulated distance from the source (S,302) to the waypoint (W), wherein the accumulated distance comprises at least the distance between the starting point and an ending point of at least one computed obstacle-free subpath from the source (S,302) to the waypoint (W), the distance being defined according to a pre-established metric; h) storing each waypoint and its corresponding priority value in a list of potential waypoints (LPW); the method characterized by i) selecting the highest priority waypoint (W) according to a minimum value of the metric in the list as a starting point (S'), and j) repeating steps b) to i) until the target (T,304) is reached; k) obtaining an optimal path by backtracking waypoints from the target (T,304) to the source (S,302); l) - guiding the vehicle according to the optimal path. a) - establishing the source (S,302) as a starting point (S'); b) - computing a subpath from the starting point (S') to the target (T,304); c) detecting if an obstacle crosses the computed subpath; d) - computing a plurality of subpaths avoiding the detected obstacle (O,510,520), each subpath connecting the starting point (S') to a waypoint (W) of an outer boundary of the detected obstacle (O,510,520); e) - detecting if a further obstacle crosses each of the plurality of subpaths; f) -repeating the steps d) - e) for each further obstacle; g) computing a priority value for each waypoint (W), wherein the priority value is computed based on: the distance between the waypoint (W) and the target (T,304) regardless of eventual obstacles located between the waypoint (W) and the target (T,304), and the accumulated distance from the source (S,302) to the waypoint (W), wherein the accumulated distance comprises at least the distance between the starting point and an ending point of at least one computed obstacle-free subpath from the source (S,302) to the waypoint (W), the distance being defined according to a pre-established metric; the distance between the waypoint (W) and the target (T,304) regardless of eventual obstacles located between the waypoint (W) and the target (T,304), and the accumulated distance from the source (S,302) to the waypoint (W), wherein the accumulated distance comprises at least the distance between the starting point and an ending point of at least one computed obstacle-free subpath from the source (S,302) to the waypoint (W), the distance being defined according to a pre-established metric; h) storing each waypoint and its corresponding priority value in a list of potential waypoints (LPW); the method characterized by i) selecting the highest priority waypoint (W) according to a minimum value of the metric in the list as a starting point (S'), and j) repeating steps b) to i) until the target (T,304) is reached; k) obtaining an optimal path by backtracking waypoints from the target (T,304) to the source (S,302); l) - guiding the vehicle according to the optimal path. <EOS>