Skip to content

Commit

Permalink
Fixed exception when using OSC scenarios without environment init (#656)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
fabianoboril committed Oct 8, 2020
1 parent c549dcd commit 0e3ce94
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
3 changes: 3 additions & 0 deletions Docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion srunner/scenarioconfigs/openscenario_configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"):
Expand Down
10 changes: 8 additions & 2 deletions srunner/tools/openscenario_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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")
Expand Down

0 comments on commit 0e3ce94

Please sign in to comment.