From 8e8dd4fc8efc625ef98b8d0eb4e01b3a71428b2e Mon Sep 17 00:00:00 2001 From: David Gasinski Date: Fri, 1 Aug 2025 14:07:21 +0100 Subject: [PATCH] refactor --- aw_scenario_runner.py | 46 +++++++++++++++++++++---------------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/aw_scenario_runner.py b/aw_scenario_runner.py index 1f4b3e8..6089838 100644 --- a/aw_scenario_runner.py +++ b/aw_scenario_runner.py @@ -120,17 +120,38 @@ def run_scenario( self.carla_world = self.carla_client.get_world() self.carla_client.load_world(env_config.town) + logger.info("Updating world settings:") + # tick asynchronously until then + settings = self.carla_world.get_settings() + settings.synchronous_mode = True + settings.fixed_delta_seconds = self._carla_config["fixed_delta_seconds"] + self.carla_world.apply_settings(settings) + + logger.info(f"{settings.__str__()}") + + if self._tm_config["active"]: + logger.info("Loading Traffic Manager...") + tm_port = int(self._tm_config["port"]) # type: ignore + CarlaDataProvider.set_traffic_manager_port(tm_port) + tm = self.carla_client.get_trafficmanager(tm_port) + + tm.set_random_device_seed(int(self._tm_config["seed"])) # ADD TO CONFIG + tm.set_synchronous_mode(self._tm_config["sync"]) + + # update the world + CarlaDataProvider.set_world(self.carla_world) + logger.info("Spawning ego...") ego = EgoVehicle(env_config) self.ego_vehicles.append(ego.spawn()) logger.info("Spawned ego...") - self.carla_world.wait_for_tick() + self.carla_world.tick() logger.info("Setting up sensor configuration...") ego.setup_sensors() - self.carla_world.wait_for_tick() + self.carla_world.tick() if not self.DEV_MODE: logger.info("Loading Autoware agent") @@ -149,27 +170,6 @@ def run_scenario( ego.prepare_ego() logger.info("Loading route...") - logger.info("Updating world settings:") - - # tick asynchronously until then - settings = self.carla_world.get_settings() - settings.synchronous_mode = True - settings.fixed_delta_seconds = self._carla_config["fixed_delta_seconds"] - self.carla_world.apply_settings(settings) - - logger.info(f"{settings.__str__()}") - - if self._tm_config["active"]: - logger.info("Loading Traffic Manager...") - tm_port = int(self._tm_config["port"]) # type: ignore - CarlaDataProvider.set_traffic_manager_port(tm_port) - tm = self.carla_client.get_trafficmanager(tm_port) - - tm.set_random_device_seed(int(self._tm_config["seed"])) # ADD TO CONFIG - tm.set_synchronous_mode(self._tm_config["sync"]) - - # update the world - CarlaDataProvider.set_world(self.carla_world) try: scenario = RouteScenario(