Bugfixes for python agents obstacle detection when empty vehicle_list is passed. (#7142)

* Bugfix for empty vehicle_list

Bug description: When an empty list is passed this fills the list with all vehicles; this is not intended. 

1) This does not allow to pass an empty list, e.g. if no vehicles are nearby.

2) On a map without pedestrians, this code is also used with an empty list which then detects cars as pedestrians.

* Update CHANGELOG.md with agent bugfix note

---------

Co-authored-by: Blyron <53337103+Blyron@users.noreply.github.com>
This commit is contained in:
Daraan 2024-02-21 11:46:20 +01:00 committed by GitHub
parent c0abf59983
commit 694ad122ac
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 5 additions and 2 deletions

View File

@ -8,6 +8,7 @@
* Added functions to get actor' bones and components names
* Added functions to get actor' sockets transforms
* make PythonAPI Windows: Fixed incompatibility issue with Anaconda due `py` command.
* Fixed bug in python agents when vehicle list was empty causing a check on all vehicles (BasicAgent.py) and detected pedestrians as vehicles if no pedestrains are present (BehaviourAgent.py)
## CARLA 0.9.15

View File

@ -349,8 +349,10 @@ class BasicAgent(object):
if self._ignore_vehicles:
return (False, None, -1)
if not vehicle_list:
if vehicle_list is None:
vehicle_list = self._world.get_actors().filter("*vehicle*")
if len(vehicle_list) == 0:
return (False, None, -1)
if not max_distance:
max_distance = self._base_vehicle_threshold