From c17849c3fcf8ec3422ff0519b08caf340a07189d Mon Sep 17 00:00:00 2001 From: Fabian Oboril Date: Mon, 19 Oct 2020 17:45:28 +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())