Skip to content

Commit 549f6d4

Browse files
fixed bug with _cleanup func calling out of bounds memory
1 parent faee1e3 commit 549f6d4

1 file changed

Lines changed: 6 additions & 13 deletions

File tree

cawsr.py

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -547,22 +547,15 @@ def destroy(self) -> None:
547547
self._cleanup()
548548
if self.scenario_manager is not None:
549549
del self.scenario_manager
550-
if self.carla_client is not None:
551-
del self.carla_client
552-
if self.carla_world is not None:
553-
del self.carla_world
554550

555551
def _cleanup(self) -> None:
556552
"""Cleanup function. Removes instances of the CARLA client and WORLD, also destroys the Ego vehicle in CARLA."""
557-
558-
if self.carla_world is not None:
559-
try:
560-
# Reset to asynchronous mode
561-
self.carla_client.get_trafficmanager(
562-
int(self._carla.TRAFFIC_MANAGER.PORT)
563-
).set_synchronous_mode(False)
564-
except RuntimeError:
565-
sys.exit(-1)
553+
try:
554+
CarlaDataProvider.get_client().get_trafficmanager(
555+
int(self._carla.TRAFFIC_MANAGER.PORT)
556+
).set_synchronous_mode(False)
557+
except RuntimeError:
558+
sys.exit(-1)
566559

567560
self.scenario_manager.cleanup()
568561

0 commit comments

Comments
 (0)