Fix division by zero in is_within_distance_ahead()

This commit is contained in:
Fabian Oboril 2019-04-02 17:23:36 +02:00 committed by nsubiron
parent 6d71c65137
commit 7451cf1008
2 changed files with 6 additions and 0 deletions

View File

@ -46,6 +46,7 @@
* Fixed floating building in Town03
* Fixed vehicles missing the route if autopilot enabled too late
* Enhanced stop triggers options
* Fixed division by zero in is_within_distance_ahead()
## CARLA 0.9.4

View File

@ -54,6 +54,11 @@ def is_within_distance_ahead(target_location, current_location, orientation, max
"""
target_vector = np.array([target_location.x - current_location.x, target_location.y - current_location.y])
norm_target = np.linalg.norm(target_vector)
# If the vector is too short, we can simply stop here
if norm_target < 0.001:
return True
if norm_target > max_distance:
return False