11#!/usr/bin/env python
22
3- # Copyright (c) 2019 Intel Corporation
3+ # Copyright (c) 2019-2021 Intel Corporation
44#
55# This work is licensed under the terms of the MIT license.
66# For a copy, see <https://opensource.org/licenses/MIT>.
@@ -124,7 +124,8 @@ def _load_catalogs(self):
124124 if catalog is None :
125125 continue
126126
127- catalog_path = catalog .find ("Directory" ).attrib .get ('path' ) + "/" + catalog_type + "Catalog.xosc"
127+ catalog_path = str (ParameterRef (catalog .find ("Directory" ).attrib .get ('path' ))) + \
128+ "/" + catalog_type + "Catalog.xosc"
128129 if not os .path .isabs (catalog_path ) and "xosc" in self .filename :
129130 catalog_path = os .path .dirname (os .path .abspath (self .filename )) + "/" + catalog_path
130131
@@ -134,10 +135,10 @@ def _load_catalogs(self):
134135 xml_tree = ET .parse (catalog_path )
135136 self ._validate_openscenario_catalog_configuration (xml_tree )
136137 catalog = xml_tree .find ("Catalog" )
137- catalog_name = catalog .attrib .get ("name" )
138+ catalog_name = str ( ParameterRef ( catalog .attrib .get ("name" )) )
138139 self .catalogs [catalog_name ] = {}
139140 for entry in catalog :
140- self .catalogs [catalog_name ][entry .attrib .get ("name" )] = entry
141+ self .catalogs [catalog_name ][str ( ParameterRef ( entry .attrib .get ("name" )) )] = entry
141142
142143 def _set_scenario_name (self ):
143144 """
@@ -158,7 +159,7 @@ def _set_carla_town(self):
158159 Hence, there can be multiple towns specified. We just use the _last_ one.
159160 """
160161 for logic in self .xml_tree .find ("RoadNetwork" ).findall ("LogicFile" ):
161- self .town = logic .attrib .get ('filepath' , None )
162+ self .town = str ( ParameterRef ( logic .attrib .get ('filepath' , None )) )
162163
163164 if self .town is not None and ".xodr" in self .town :
164165 if not os .path .isabs (self .town ):
@@ -235,7 +236,7 @@ def _set_actor_information(self):
235236 """
236237 for entity in self .xml_tree .iter ("Entities" ):
237238 for obj in entity .iter ("ScenarioObject" ):
238- rolename = obj .attrib .get ('name' , 'simulation' )
239+ rolename = str ( ParameterRef ( obj .attrib .get ('name' , 'simulation' )) )
239240 args = {}
240241 for prop in obj .iter ("Property" ):
241242 key = prop .get ('name' )
@@ -290,8 +291,8 @@ def _extract_vehicle_information(self, obj, rolename, vehicle, args):
290291 Helper function to _set_actor_information for getting vehicle information from XML tree
291292 """
292293 color = None
293- model = vehicle .attrib .get ('name' , "vehicle.*" )
294- category = vehicle .attrib .get ('vehicleCategory' , "car" )
294+ model = str ( ParameterRef ( vehicle .attrib .get ('name' , "vehicle.*" )) )
295+ category = str ( ParameterRef ( vehicle .attrib .get ('vehicleCategory' , "car" )) )
295296 ego_vehicle = False
296297 for prop in obj .iter ("Property" ):
297298 if prop .get ('name' , '' ) == 'type' :
@@ -312,7 +313,7 @@ def _extract_pedestrian_information(self, obj, rolename, pedestrian, args):
312313 """
313314 Helper function to _set_actor_information for getting pedestrian information from XML tree
314315 """
315- model = pedestrian .attrib .get ('model' , "walker.*" )
316+ model = str ( ParameterRef ( pedestrian .attrib .get ('model' , "walker.*" )) )
316317
317318 speed = self ._get_actor_speed (rolename )
318319 new_actor = ActorConfigurationData (model , None , rolename , speed , category = "pedestrian" , args = args )
@@ -323,13 +324,13 @@ def _extract_misc_information(self, obj, rolename, misc, args):
323324 """
324325 Helper function to _set_actor_information for getting vehicle information from XML tree
325326 """
326- category = misc .attrib .get ('miscObjectCategory' )
327+ category = str ( ParameterRef ( misc .attrib .get ('miscObjectCategory' )) )
327328 if category == "barrier" :
328329 model = "static.prop.streetbarrier"
329330 elif category == "guardRail" :
330331 model = "static.prop.chainbarrier"
331332 else :
332- model = misc .attrib .get ('name' )
333+ model = str ( ParameterRef ( misc .attrib .get ('name' )) )
333334 new_actor = ActorConfigurationData (model , None , rolename , category = "misc" , args = args )
334335
335336 self .other_actors .append (new_actor )
@@ -351,7 +352,7 @@ def _get_actor_transform(self, actor_name):
351352 actor_found = False
352353
353354 for private_action in self .init .iter ("Private" ):
354- if private_action .attrib .get ('entityRef' , None ) == actor_name :
355+ if str ( ParameterRef ( private_action .attrib .get ('entityRef' , None )) ) == actor_name :
355356 if actor_found :
356357 # pylint: disable=line-too-long
357358 self .logger .warning (
@@ -380,7 +381,7 @@ def _get_actor_speed(self, actor_name):
380381 actor_found = False
381382
382383 for private_action in self .init .iter ("Private" ):
383- if private_action .attrib .get ('entityRef' , None ) == actor_name :
384+ if str ( ParameterRef ( private_action .attrib .get ('entityRef' , None )) ) == actor_name :
384385 if actor_found :
385386 # pylint: disable=line-too-long
386387 self .logger .warning (
0 commit comments