Closed 00Dan00 closed 3 days ago
Sorry not sure why the code is formated this poorly.
So in general .destroy() just sometimes crashes my environment
You have to call at least one time tick() after the creation of vehicles in order to be able to destroying them properly.
CARLA
version: 0.9.15 Platform/OS: Windows Problem you have experienced: I'm spawning actors that run on autopilot. When spawning I add the corresponding actor to a list to later destroy that actor. But once I call the destroy method the simulation & my kernel crashes and I get no error message. What you expected to happen: The corresponding (or all) actors to be destroyed (removed from the simulation) and the simulation still running Steps to reproduce: From my notebook. Everything works fine and my cars get spawned but once I run the last cell with the vehicle.destroy() method everything crashes.``
import carla import random import time
client = carla.Client('localhost', 2000) client.set_timeout(5.0) world = client.get_world() spawn_points = world.get_map().get_spawn_points() spawnedcars = [] for in range(60): car_blueprint = random.choice(world.get_blueprint_library().filter("vehicle")) if car_blueprint.has_attribute('color'): color = random.choice(car_blueprint.get_attribute('color').recommended_values) car_blueprint.set_attribute('color', color) car_blueprint.set_attribute('role_name', 'autopilot')
for vehicle in spawned_cars: try: vehicle.destroy() except Exception as e: print("Failed to destroy car:", e)
``