diff --git a/assets/behavior_metrics_full_architecture.png b/assets/behavior_metrics_full_architecture.png deleted file mode 100644 index d69552c0..00000000 Binary files a/assets/behavior_metrics_full_architecture.png and /dev/null differ diff --git a/behavior_metrics/brains/CARLA/brain_carla_subjective_vision_deep_learning_previous_v.py b/behavior_metrics/brains/CARLA/brain_carla_subjective_vision_deep_learning_previous_v.py index d9d46ec1..7b967041 100644 --- a/behavior_metrics/brains/CARLA/brain_carla_subjective_vision_deep_learning_previous_v.py +++ b/behavior_metrics/brains/CARLA/brain_carla_subjective_vision_deep_learning_previous_v.py @@ -77,7 +77,10 @@ def __init__(self, sensors, actuators, handler, model, config=None): self.world.unload_map_layer(carla.MapLayer.Particles) time.sleep(5) - self.vehicle = self.world.get_actors().filter('vehicle.*')[0] + self.vehicle = next( + (p for p in self.world.get_actors() if 'vehicle' in p.type_id and p.attributes.get('role_name') == 'ego_vehicle'), + None + ) if model: if not path.exists(PRETRAINED_MODELS + model): @@ -195,7 +198,7 @@ def execute(self): self.motors.sendThrottle(throttle) self.motors.sendSteer(steer) self.motors.sendBrake(break_command) - + if vehicle_speed >= 35: self.motors.sendThrottle(0.0) self.motors.sendBrake(0.0) diff --git a/behavior_metrics/configs/CARLA/CARLA_launch_files/CARLA_object_files/main_car.json b/behavior_metrics/configs/CARLA/CARLA_launch_files/CARLA_object_files/main_car.json index d687d1c9..0a9d8fce 100644 --- a/behavior_metrics/configs/CARLA/CARLA_launch_files/CARLA_object_files/main_car.json +++ b/behavior_metrics/configs/CARLA/CARLA_launch_files/CARLA_object_files/main_car.json @@ -156,6 +156,22 @@ "id": "control" } ] + }, + { + "type": "vehicle.audi.a2", + "id": "npc_vehicle_1", + "spawn_point": {"x": 60.0, "y": 2.0, "z": 1.37, "roll": 0.0, "pitch": 0.0, "yaw": 180.0}, + "sensors": + [ + { + "type": "sensor.pseudo.objects", + "id": "objects" + }, + { + "type": "sensor.pseudo.odom", + "id": "odometry" + } + ] } ] } diff --git a/behavior_metrics/configs/CARLA/CARLA_launch_files/town_02_anticlockwise_low.launch b/behavior_metrics/configs/CARLA/CARLA_launch_files/town_02_anticlockwise_low.launch index d9823d00..9fb43704 100644 --- a/behavior_metrics/configs/CARLA/CARLA_launch_files/town_02_anticlockwise_low.launch +++ b/behavior_metrics/configs/CARLA/CARLA_launch_files/town_02_anticlockwise_low.launch @@ -19,7 +19,7 @@ - + @@ -62,13 +62,20 @@ - - - - - - - + + + + + + + + + + + + + + diff --git a/behavior_metrics/configs/CARLA/default_carla_subjective_vision.yml b/behavior_metrics/configs/CARLA/default_carla_subjective_vision.yml index c72ab5d8..1e8eb2a6 100644 --- a/behavior_metrics/configs/CARLA/default_carla_subjective_vision.yml +++ b/behavior_metrics/configs/CARLA/default_carla_subjective_vision.yml @@ -49,6 +49,7 @@ Behaviors: Simulation: World: configs/CARLA/CARLA_launch_files/town_02_anticlockwise_low.launch RandomSpawnPoint: False + MultiCar: True Dataset: In: '/tmp/my_bag.bag' Out: '' diff --git a/behavior_metrics/utils/configuration.py b/behavior_metrics/utils/configuration.py index 02adf75a..156d2376 100644 --- a/behavior_metrics/utils/configuration.py +++ b/behavior_metrics/utils/configuration.py @@ -141,6 +141,11 @@ def initialize_configuration(self, config_data): else: self.spawn_points = [] + if 'MultiCar' in config_data['Behaviors']['Simulation']: + self.multicar = config_data['Behaviors']['Simulation']['MultiCar'] + else: + self.multicar = False + if 'NumberOfVehicle' in config_data['Behaviors']['Simulation']: self.number_of_vehicle = config_data['Behaviors']['Simulation']['NumberOfVehicle'] else: diff --git a/behavior_metrics/utils/traffic.py b/behavior_metrics/utils/traffic.py index e910f19f..4bb1680a 100644 --- a/behavior_metrics/utils/traffic.py +++ b/behavior_metrics/utils/traffic.py @@ -34,6 +34,11 @@ def __init__(self, n_vehicle, n_walker, percentage_walker_running=0.0, percentag self.walker_ids = [] def generate_traffic(self): + for p in self.world.get_actors(): + if 'vehicle' in p.type_id: + if p.attributes['role_name'] != 'ego_vehicle': + set_autopilot(p, True, self.traffic_manager.get_port()) + if self.n_vehicle > 0: self.spawn_vehicles(self.world, self.client, self.n_vehicle, self.traffic_manager) if self.n_walker > 0: @@ -105,7 +110,8 @@ def spawn_vehicles(self, world, client, n_vehicles, traffic_manager): if blueprint.has_attribute('driver_id'): driver_id = random.choice(blueprint.get_attribute('driver_id').recommended_values) blueprint.set_attribute('driver_id', driver_id) - blueprint.set_attribute('role_name', 'autopilot') + blueprint.set_attribute('role_name', 'npc_vehicle_1') + batch.append(spawn_actor(blueprint, transform) .then(set_autopilot(future_actor, True, traffic_manager.get_port())))