From 5ca1878b8b9f94a8ac6e3e511645ac00155a4e0d Mon Sep 17 00:00:00 2001 From: Fabian Oboril Date: Tue, 20 Oct 2020 11:35:45 +0200 Subject: [PATCH] Fixed handling of Weather in OSC Fixed an issue introduced 3 commits before (#656) --- srunner/tools/openscenario_parser.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/srunner/tools/openscenario_parser.py b/srunner/tools/openscenario_parser.py index 63bd4dc15..86cd2f38a 100644 --- a/srunner/tools/openscenario_parser.py +++ b/srunner/tools/openscenario_parser.py @@ -284,8 +284,10 @@ def get_friction_from_env_action(xml_tree, catalogs): returns: friction (float) """ - if xml_tree.find("EnvironmentAction") is not None: - set_environment = next(xml_tree.iter("EnvironmentAction")) + + if xml_tree.findall('.//EnvironmentAction'): + node = xml_tree.findall('.//EnvironmentAction')[0] + set_environment = next(node.iter("EnvironmentAction")) else: return 1.0 @@ -316,8 +318,10 @@ def get_weather_from_env_action(xml_tree, catalogs): returns: Weather (srunner.scenariomanager.weather_sim.Weather) """ - if xml_tree.find("EnvironmentAction") is not None: - set_environment = next(xml_tree.iter("EnvironmentAction")) + + if xml_tree.findall('.//EnvironmentAction'): + node = xml_tree.findall('.//EnvironmentAction')[0] + set_environment = next(node.iter("EnvironmentAction")) else: return Weather(carla.WeatherParameters())