From 0e3ce9461dfe12f5ab837d46919830ff0e6ae65d Mon Sep 17 00:00:00 2001 From: Fabian Oboril Date: Thu, 8 Oct 2020 15:36:44 +0200 Subject: [PATCH] Fixed exception when using OSC scenarios without environment init (#656) * Fixed exception when using OSC scenarios without environment init OpenSCENARIO based scenarios that do not use an EnvironmentAction inside the Storyboard Init part, are no longer throwing an exception. Change-Id: Icda0bd6022cbde04da2e9e043eb3774d5acde548 --- Docs/CHANGELOG.md | 3 +++ srunner/scenarioconfigs/openscenario_configuration.py | 2 +- srunner/tools/openscenario_parser.py | 10 ++++++++-- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/Docs/CHANGELOG.md b/Docs/CHANGELOG.md index 7af0a88f8..4dfa73da0 100644 --- a/Docs/CHANGELOG.md +++ b/Docs/CHANGELOG.md @@ -13,6 +13,9 @@ ### :rocket: New Features * Added a sensor barrier for the agents to ensure that the simulation waits for them to render their data. * Added an option to produce a machine-readable JSON version of the scenario report. +### :bug: Bug Fixes +* Fixed exception when using OSC scenarios without EnvironmentAction inside Storyboard-Init + ## CARLA ScenarioRunner 0.9.10 ### :rocket: New Features diff --git a/srunner/scenarioconfigs/openscenario_configuration.py b/srunner/scenarioconfigs/openscenario_configuration.py index 6934b0c40..02c118b87 100644 --- a/srunner/scenarioconfigs/openscenario_configuration.py +++ b/srunner/scenarioconfigs/openscenario_configuration.py @@ -220,7 +220,7 @@ def _set_actor_information(self): elif entry.tag == "MiscObject": self._extract_misc_information(entry, rolename, entry, args) else: - self.logger.error( + self.logger.debug( " A CatalogReference specifies a reference that is not an Entity. Skipping...") for vehicle in obj.iter("Vehicle"): diff --git a/srunner/tools/openscenario_parser.py b/srunner/tools/openscenario_parser.py index 6b05cc433..13f60e3f8 100644 --- a/srunner/tools/openscenario_parser.py +++ b/srunner/tools/openscenario_parser.py @@ -269,7 +269,10 @@ def get_friction_from_env_action(xml_tree, catalogs): returns: friction (float) """ - set_environment = next(xml_tree.iter("EnvironmentAction")) + if xml_tree.find("EnvironmentAction") is not None: + set_environment = next(xml_tree.iter("EnvironmentAction")) + else: + return 1.0 if sum(1 for _ in set_environment.iter("Weather")) != 0: environment = set_environment.find("Environment") @@ -298,7 +301,10 @@ def get_weather_from_env_action(xml_tree, catalogs): returns: Weather (srunner.scenariomanager.weather_sim.Weather) """ - set_environment = next(xml_tree.iter("EnvironmentAction")) + if xml_tree.find("EnvironmentAction") is not None: + set_environment = next(xml_tree.iter("EnvironmentAction")) + else: + return Weather(carla.WeatherParameters()) if sum(1 for _ in set_environment.iter("Weather")) != 0: environment = set_environment.find("Environment")