From 4cc590359486496b426f4ed487243b5ac7986f11 Mon Sep 17 00:00:00 2001 From: sergi-e Date: Thu, 15 Oct 2020 17:18:17 +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 13f60e3f8..11a35f533 100644 --- a/srunner/tools/openscenario_parser.py +++ b/srunner/tools/openscenario_parser.py @@ -269,8 +269,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 @@ -301,8 +303,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())