Skip to content

Commit

Permalink
Added support for multiple Stories within one OSC Storyboard
Browse files Browse the repository at this point in the history
  • Loading branch information
fabianoboril committed Mar 12, 2021
1 parent ca1a696 commit 5465298
Show file tree
Hide file tree
Showing 2 changed files with 154 additions and 139 deletions.
24 changes: 17 additions & 7 deletions srunner/scenarioconfigs/openscenario_configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def __init__(self, filename, client, custom_params):
self.weather = carla.WeatherParameters()

self.storyboard = self.xml_tree.find("Storyboard")
self.story = self.storyboard.find("Story")
self.stories = self.storyboard.findall("Story")
self.init = self.storyboard.find("Init")

logging.basicConfig()
Expand All @@ -61,7 +61,7 @@ def __init__(self, filename, client, custom_params):

def _validate_openscenario_configuration(self):
"""
Validate the given OpenSCENARIO config against the 0.9.1 XSD
Validate the given OpenSCENARIO config against the 1.0 XSD
Note: This will throw if the config is not valid. But this is fine here.
"""
Expand All @@ -71,7 +71,7 @@ def _validate_openscenario_configuration(self):

def _validate_openscenario_catalog_configuration(self, catalog_xml_tree):
"""
Validate the given OpenSCENARIO catalog config against the 0.9.1 XSD
Validate the given OpenSCENARIO catalog config against the 1.0 XSD
Note: This will throw if the catalog config is not valid. But this is fine here.
"""
Expand Down Expand Up @@ -168,15 +168,25 @@ def _set_carla_town(self):

# workaround for relative positions during init
world = self.client.get_world()
if world is None or world.get_map().name != self.town:
self.logger.warning(" Wrong OpenDRIVE map in use. Forcing reload of CARLA world")
wmap = None
if world:
wmap = world.get_map()

if world is None or (wmap is not None and wmap.name != self.town):
if ".xodr" in self.town:
with open(self.town) as od_file:
data = od_file.read()
self.client.generate_opendrive_world(str(data))
old_map = ""
if wmap is not None:
old_map = wmap.to_opendrive()
if data != old_map:
self.logger.warning(" Wrong OpenDRIVE map in use. Forcing reload of CARLA world")
self.client.generate_opendrive_world(str(data))
world = self.client.get_world()
else:
self.logger.warning(" Wrong map in use. Forcing reload of CARLA world")
self.client.load_world(self.town)
world = self.client.get_world()
world = self.client.get_world()
CarlaDataProvider.set_world(world)
world.wait_for_tick()
else:
Expand Down
Loading

0 comments on commit 5465298

Please sign in to comment.