Skip to content

Commit

Permalink
Use model string in ros_gz_spawn_model.launch.py (gazebosim#605)
Browse files Browse the repository at this point in the history
Signed-off-by: Carlos Agüero <[email protected]>
  • Loading branch information
caguero authored and Amronos committed Sep 18, 2024
1 parent 40a2f6a commit c8fb8ba
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
10 changes: 5 additions & 5 deletions ros_gz_sim/launch/ros_gz_spawn_model.launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down Expand Up @@ -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',
)
Expand Down Expand Up @@ -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),
Expand All @@ -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)
Expand Down
18 changes: 9 additions & 9 deletions ros_gz_sim/ros_gz_sim/actions/gz_spawn_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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.
Expand All @@ -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
Expand All @@ -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(
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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),
Expand Down

0 comments on commit c8fb8ba

Please sign in to comment.