From 66c7a4a5b41bc2466f2334e216f0434a10303fdc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Ag=C3=BCero?= Date: Wed, 11 Sep 2024 21:51:10 +0200 Subject: [PATCH] Use model string in ros_gz_spawn_model.launch.py (#605) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Carlos Agüero --- ros_gz_sim/launch/ros_gz_spawn_model.launch.py | 10 +++++----- .../ros_gz_sim/actions/gz_spawn_model.py | 18 +++++++++--------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/ros_gz_sim/launch/ros_gz_spawn_model.launch.py b/ros_gz_sim/launch/ros_gz_spawn_model.launch.py index 245edbeb..85359bb6 100644 --- a/ros_gz_sim/launch/ros_gz_spawn_model.launch.py +++ b/ros_gz_sim/launch/ros_gz_spawn_model.launch.py @@ -33,7 +33,7 @@ def generate_launch_description(): world = LaunchConfiguration('world') file = LaunchConfiguration('file') - world_string = LaunchConfiguration('world_string') + model_string = LaunchConfiguration('model_string') topic = LaunchConfiguration('topic') entity_name = LaunchConfiguration('entity_name') allow_renaming = LaunchConfiguration('allow_renaming') @@ -84,8 +84,8 @@ def generate_launch_description(): 'file', default_value=TextSubstitution(text=''), description='SDF filename') - declare_world_string_cmd = DeclareLaunchArgument( - 'world_string', + declare_model_string_cmd = DeclareLaunchArgument( + 'model_string', default_value='', description='XML string', ) @@ -125,7 +125,7 @@ def generate_launch_description(): 'gz_spawn_model.launch.py'])]), launch_arguments=[('world', world), ('file', file), - ('world_string', world_string), + ('model_string', model_string), ('topic', topic), ('entity_name', entity_name), ('allow_renaming', allow_renaming), @@ -149,7 +149,7 @@ def generate_launch_description(): ld.add_action(declare_log_level_cmd) ld.add_action(declare_world_cmd) ld.add_action(declare_file_cmd) - ld.add_action(declare_world_string_cmd) + ld.add_action(declare_model_string_cmd) ld.add_action(declare_topic_cmd) ld.add_action(declare_entity_name_cmd) ld.add_action(declare_allow_renaming_cmd) diff --git a/ros_gz_sim/ros_gz_sim/actions/gz_spawn_model.py b/ros_gz_sim/ros_gz_sim/actions/gz_spawn_model.py index 95992652..874aff33 100644 --- a/ros_gz_sim/ros_gz_sim/actions/gz_spawn_model.py +++ b/ros_gz_sim/ros_gz_sim/actions/gz_spawn_model.py @@ -36,7 +36,7 @@ def __init__( *, world: Optional[SomeSubstitutionsType] = None, file: Optional[SomeSubstitutionsType] = None, - world_string: Optional[SomeSubstitutionsType] = None, + model_string: Optional[SomeSubstitutionsType] = None, topic: Optional[SomeSubstitutionsType] = None, entity_name: Optional[SomeSubstitutionsType] = None, allow_renaming: Optional[SomeSubstitutionsType] = None, @@ -56,7 +56,7 @@ def __init__( :param: world World name. :param: file SDF filename. - :param: world_string XML string. + :param: model_string XML string. :param: topic Get XML from this topic. :param: entity_name Name of the entity. :param: allow_renaming Whether the entity allows renaming or not. @@ -70,7 +70,7 @@ def __init__( super().__init__(**kwargs) self.__world = world self.__file = file - self.__world_string = world_string + self.__model_string = model_string self.__topic = topic self.__entity_name = entity_name self.__allow_renaming = allow_renaming @@ -94,8 +94,8 @@ def parse(cls, entity: Entity, parser: Parser): 'file', data_type=str, optional=True) - world_string = entity.get_attr( - 'world_string', data_type=str, + model_string = entity.get_attr( + 'model_string', data_type=str, optional=True) topic = entity.get_attr( @@ -142,9 +142,9 @@ def parse(cls, entity: Entity, parser: Parser): file = parser.parse_substitution(file) kwargs['file'] = file - if isinstance(world_string, str): - world_string = parser.parse_substitution(world_string) - kwargs['world_string'] = world_string + if isinstance(model_string, str): + model_string = parser.parse_substitution(model_string) + kwargs['model_string'] = model_string if isinstance(topic, str): topic = parser.parse_substitution(topic) @@ -193,7 +193,7 @@ def execute(self, context: LaunchContext) -> Optional[List[Action]]: 'gz_spawn_model.launch.py'])]), launch_arguments=[('world', self.__world), ('file', self.__file), - ('world_string', self.__world_string), + ('model_string', self.__model_string), ('topic', self.__topic), ('entity_name', self.__entity_name), ('allow_renaming', self.__allow_renaming),