Fix division by zero in is_within_distance_ahead()
This commit is contained in:
parent
6d71c65137
commit
7451cf1008
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in New Issue