Skip to content

Commit

Permalink
Fix errors with name of bridge not being given (gazebosim#600)
Browse files Browse the repository at this point in the history
* Add argument bridge_name to fix errors

Signed-off-by: Aarav Gupta <134804732+Amronos@users.noreply.github.com>
  • Loading branch information
Amronos committed Sep 12, 2024
1 parent cde55b5 commit 9fae54b
Show file tree
Hide file tree
Showing 9 changed files with 57 additions and 44 deletions.
4 changes: 2 additions & 2 deletions ros_gz_bridge/launch/ros_gz_bridge.launch
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<launch>
<arg name="name" />
<arg name="bridge_name" />
<arg name="config_file" default="" />
<arg name="container_name" default="ros_gz_container" />
<arg name="namespace" default="" />
<arg name="use_composition" default="True" />
<arg name="use_respawn" default="False" />
<arg name="log_level" default="info" />
<ros_gz_bridge
name="$(var name)"
bridge_name="$(var bridge_name)"
config_file="$(var config_file)"
container_name="$(var container_name)"
namespace="$(var namespace)"
Expand Down
12 changes: 6 additions & 6 deletions ros_gz_bridge/launch/ros_gz_bridge.launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,16 @@

def generate_launch_description():

name = LaunchConfiguration('name')
bridge_name = LaunchConfiguration('bridge_name')
config_file = LaunchConfiguration('config_file')
container_name = LaunchConfiguration('container_name')
namespace = LaunchConfiguration('namespace')
use_composition = LaunchConfiguration('use_composition')
use_respawn = LaunchConfiguration('use_respawn')
log_level = LaunchConfiguration('log_level')

declare_name_cmd = DeclareLaunchArgument(
'name', description='Name of ros_gz_bridge node'
declare_bridge_name_cmd = DeclareLaunchArgument(
'bridge_name', description='Name of ros_gz_bridge node'
)

declare_config_file_cmd = DeclareLaunchArgument(
Expand Down Expand Up @@ -70,7 +70,7 @@ def generate_launch_description():
Node(
package='ros_gz_bridge',
executable='bridge_node',
name=name,
name=bridge_name,
namespace=namespace,
output='screen',
respawn=use_respawn,
Expand All @@ -88,7 +88,7 @@ def generate_launch_description():
ComposableNode(
package='ros_gz_bridge',
plugin='ros_gz_bridge::RosGzBridge',
name=name,
name=bridge_name,
namespace=namespace,
parameters=[{'config_file': config_file}],
extra_arguments=[{'use_intra_process_comms': True}],
Expand All @@ -100,7 +100,7 @@ def generate_launch_description():
ld = LaunchDescription()

# Declare the launch options
ld.add_action(declare_name_cmd)
ld.add_action(declare_bridge_name_cmd)
ld.add_action(declare_config_file_cmd)
ld.add_action(declare_container_name_cmd)
ld.add_action(declare_namespace_cmd)
Expand Down
18 changes: 9 additions & 9 deletions ros_gz_bridge/ros_gz_bridge/actions/ros_gz_bridge.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class RosGzBridge(Action):
def __init__(
self,
*,
name: SomeSubstitutionsType,
bridge_name: SomeSubstitutionsType,
config_file: SomeSubstitutionsType,
container_name: Optional[SomeSubstitutionsType] = 'ros_gz_container',
namespace: Optional[SomeSubstitutionsType] = '',
Expand All @@ -49,7 +49,7 @@ def __init__(
All arguments are forwarded to `ros_gz_bridge.launch.ros_gz_bridge.launch.py`,
so see the documentation of that class for further details.
:param: name Name of ros_gz_bridge node
:param: bridge_name Name of ros_gz_bridge node
:param: config_file YAML config file.
:param: container_name Name of container that nodes will load in if use composition.
:param: namespace Top-level namespace.
Expand All @@ -58,7 +58,7 @@ def __init__(
:param: log_level Log level.
"""
super().__init__(**kwargs)
self.__name = name
self.__bridge_name = bridge_name
self.__config_file = config_file
self.__container_name = container_name
self.__namespace = namespace
Expand All @@ -71,8 +71,8 @@ def parse(cls, entity: Entity, parser: Parser):
"""Parse ros_gz_bridge."""
_, kwargs = super().parse(entity, parser)

name = entity.get_attr(
'name', data_type=str,
bridge_name = entity.get_attr(
'bridge_name', data_type=str,
optional=False)

config_file = entity.get_attr(
Expand All @@ -99,9 +99,9 @@ def parse(cls, entity: Entity, parser: Parser):
'log_level', data_type=str,
optional=True)

if isinstance(name, str):
name = parser.parse_substitution(name)
kwargs['name'] = name
if isinstance(bridge_name, str):
bridge_name = parser.parse_substitution(bridge_name)
kwargs['bridge_name'] = bridge_name

if isinstance(config_file, str):
config_file = parser.parse_substitution(config_file)
Expand Down Expand Up @@ -136,7 +136,7 @@ def execute(self, context: LaunchContext) -> Optional[List[Action]]:
[PathJoinSubstitution([FindPackageShare('ros_gz_bridge'),
'launch',
'ros_gz_bridge.launch.py'])]),
launch_arguments=[('name', self.__name),
launch_arguments=[('bridge_name', self.__bridge_name),
('config_file', self.__config_file),
('container_name', self.__container_name),
('namespace', self.__namespace),
Expand Down
4 changes: 2 additions & 2 deletions ros_gz_sim/launch/gz_spawn_model.launch
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<arg name="file" default="" />
<arg name="xml_string" default="" />
<arg name="topic" default="" />
<arg name="name" default="" />
<arg name="entity_name" default="" />
<arg name="allow_renaming" default="False" />
<arg name="x" default="" />
<arg name="y" default="" />
Expand All @@ -16,7 +16,7 @@
file="$(var file)"
xml_string="$(var xml_string)"
topic="$(var topic)"
name="$(var name)"
entity_name="$(var entity_name)"
allow_renaming="$(var allow_renaming)"
x="$(var x)"
y="$(var y)"
Expand Down
10 changes: 5 additions & 5 deletions ros_gz_sim/launch/gz_spawn_model.launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def generate_launch_description():
file = LaunchConfiguration('file')
xml_string = LaunchConfiguration('string')
topic = LaunchConfiguration('topic')
name = LaunchConfiguration('name')
entity_name = LaunchConfiguration('entity_name')
allow_renaming = LaunchConfiguration('allow_renaming')
x = LaunchConfiguration('x', default='0.0')
y = LaunchConfiguration('y', default='0.0')
Expand All @@ -50,8 +50,8 @@ def generate_launch_description():
'topic', default_value=TextSubstitution(text=''),
description='Get XML from this topic'
)
declare_name_cmd = DeclareLaunchArgument(
'name', default_value=TextSubstitution(text=''),
declare_entity_name_cmd = DeclareLaunchArgument(
'entity_name', default_value=TextSubstitution(text=''),
description='Name of the entity'
)
declare_allow_renaming_cmd = DeclareLaunchArgument(
Expand All @@ -67,7 +67,7 @@ def generate_launch_description():
'file': file,
'string': xml_string,
'topic': topic,
'name': name,
'name': entity_name,
'allow_renaming': allow_renaming,
'x': x,
'y': y,
Expand All @@ -86,7 +86,7 @@ def generate_launch_description():
ld.add_action(declare_file_cmd)
ld.add_action(declare_xml_string_cmd)
ld.add_action(declare_topic_cmd)
ld.add_action(declare_name_cmd)
ld.add_action(declare_entity_name_cmd)
ld.add_action(declare_allow_renaming_cmd)
# Add the actions to launch all of the create nodes
ld.add_action(load_nodes)
Expand Down
4 changes: 2 additions & 2 deletions ros_gz_sim/launch/ros_gz_sim.launch
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<launch>
<arg name="name" />
<arg name="bridge_name" />
<arg name="config_file" default="" />
<arg name="container_name" default="ros_gz_container" />
<arg name="namespace" default="" />
Expand All @@ -15,7 +15,7 @@
use_composition="$(var use_composition)">
</gz_server>
<ros_gz_bridge
name="$(var name)"
bridge_name="$(var bridge_name)"
config_file="$(var config_file)"
container_name="$(var container_name)"
namespace="$(var namespace)"
Expand Down
9 changes: 8 additions & 1 deletion ros_gz_sim/launch/ros_gz_sim.launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

def generate_launch_description():

bridge_name = LaunchConfiguration('bridge_name')
config_file = LaunchConfiguration('config_file')
container_name = LaunchConfiguration('container_name')
namespace = LaunchConfiguration('namespace')
Expand All @@ -33,6 +34,10 @@ def generate_launch_description():
world_sdf_file = LaunchConfiguration('world_sdf_file')
world_sdf_string = LaunchConfiguration('world_sdf_string')

declare_bridge_name_cmd = DeclareLaunchArgument(
'bridge_name', default_value='', description='Name of the bridge'
)

declare_config_file_cmd = DeclareLaunchArgument(
'config_file', default_value='', description='YAML config file'
)
Expand Down Expand Up @@ -76,7 +81,8 @@ def generate_launch_description():
[PathJoinSubstitution([FindPackageShare('ros_gz_bridge'),
'launch',
'ros_gz_bridge.launch.py'])]),
launch_arguments=[('config_file', config_file),
launch_arguments=[('bridge_name', bridge_name),
('config_file', config_file),
('container_name', container_name),
('namespace', namespace),
('use_composition', use_composition),
Expand All @@ -96,6 +102,7 @@ def generate_launch_description():
ld = LaunchDescription()

# Declare the launch options
ld.add_action(declare_bridge_name_cmd)
ld.add_action(declare_config_file_cmd)
ld.add_action(declare_container_name_cmd)
ld.add_action(declare_namespace_cmd)
Expand Down
22 changes: 14 additions & 8 deletions ros_gz_sim/launch/ros_gz_spawn_model.launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

def generate_launch_description():

bridge_name = LaunchConfiguration('bridge_name')
config_file = LaunchConfiguration('config_file')
container_name = LaunchConfiguration('container_name')
namespace = LaunchConfiguration('namespace')
Expand All @@ -34,7 +35,7 @@ def generate_launch_description():
file = LaunchConfiguration('file')
xml_string = LaunchConfiguration('string')
topic = LaunchConfiguration('topic')
name = LaunchConfiguration('name')
entity_name = LaunchConfiguration('entity_name')
allow_renaming = LaunchConfiguration('allow_renaming')
x = LaunchConfiguration('x', default='0.0')
y = LaunchConfiguration('y', default='0.0')
Expand All @@ -43,6 +44,10 @@ def generate_launch_description():
pitch = LaunchConfiguration('P', default='0.0')
yaw = LaunchConfiguration('Y', default='0.0')

declare_bridge_name_cmd = DeclareLaunchArgument(
'bridge_name', default_value='', description='Name of the bridge'
)

declare_config_file_cmd = DeclareLaunchArgument(
'config_file', default_value='', description='YAML config file'
)
Expand Down Expand Up @@ -90,8 +95,8 @@ def generate_launch_description():
description='Get XML from this topic'
)

declare_name_cmd = DeclareLaunchArgument(
'name', default_value=TextSubstitution(text=''),
declare_entity_name_cmd = DeclareLaunchArgument(
'entity_name', default_value=TextSubstitution(text=''),
description='Name of the entity'
)

Expand All @@ -105,7 +110,8 @@ def generate_launch_description():
[PathJoinSubstitution([FindPackageShare('ros_gz_bridge'),
'launch',
'ros_gz_bridge.launch.py'])]),
launch_arguments=[('config_file', config_file),
launch_arguments=[('bridge_name', bridge_name),
('config_file', config_file),
('container_name', container_name),
('namespace', namespace),
('use_composition', use_composition),
Expand All @@ -121,20 +127,20 @@ def generate_launch_description():
('file', file),
('xml_string', xml_string),
('topic', topic),
('name', name),
('entity_name', entity_name),
('allow_renaming', allow_renaming),
('x', x),
('y', y),
('z', z),
('R', roll),
('P', pitch),
('Y', yaw),
('use_composition', use_composition), ])
('Y', yaw), ])

# Create the launch description and populate
ld = LaunchDescription()

# Declare the launch options
ld.add_action(declare_bridge_name_cmd)
ld.add_action(declare_config_file_cmd)
ld.add_action(declare_container_name_cmd)
ld.add_action(declare_namespace_cmd)
Expand All @@ -145,7 +151,7 @@ def generate_launch_description():
ld.add_action(declare_file_cmd)
ld.add_action(declare_xml_string_cmd)
ld.add_action(declare_topic_cmd)
ld.add_action(declare_name_cmd)
ld.add_action(declare_entity_name_cmd)
ld.add_action(declare_allow_renaming_cmd)
# Add the actions to launch all of the bridge + spawn_model nodes
ld.add_action(bridge_description)
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 @@ -38,7 +38,7 @@ def __init__(
file: Optional[SomeSubstitutionsType] = None,
xml_string: Optional[SomeSubstitutionsType] = None,
topic: Optional[SomeSubstitutionsType] = None,
name: Optional[SomeSubstitutionsType] = None,
entity_name: Optional[SomeSubstitutionsType] = None,
allow_renaming: Optional[SomeSubstitutionsType] = None,
x: Optional[SomeSubstitutionsType] = None,
y: Optional[SomeSubstitutionsType] = None,
Expand All @@ -58,7 +58,7 @@ def __init__(
:param: file SDF filename.
:param: xml_string XML string.
:param: topic Get XML from this topic.
:param: name Name of the entity.
:param: entity_name Name of the entity.
:param: allow_renaming Whether the entity allows renaming or not.
:param: x X coordinate.
:param: y Y coordinate.
Expand All @@ -72,7 +72,7 @@ def __init__(
self.__file = file
self.__xml_string = xml_string
self.__topic = topic
self.__name = name
self.__entity_name = entity_name
self.__allow_renaming = allow_renaming
self.__x = x
self.__y = y
Expand Down Expand Up @@ -102,8 +102,8 @@ def parse(cls, entity: Entity, parser: Parser):
'topic', data_type=str,
optional=True)

name = entity.get_attr(
'name', data_type=str,
entity_name = entity.get_attr(
'entity_name', data_type=str,
optional=True)

allow_renaming = entity.get_attr(
Expand Down Expand Up @@ -150,9 +150,9 @@ def parse(cls, entity: Entity, parser: Parser):
topic = parser.parse_substitution(topic)
kwargs['topic'] = topic

if isinstance(name, str):
name = parser.parse_substitution(name)
kwargs['name'] = name
if isinstance(entity_name, str):
entity_name = parser.parse_substitution(entity_name)
kwargs['entity_name'] = entity_name

if isinstance(allow_renaming, str):
allow_renaming = parser.parse_substitution(allow_renaming)
Expand Down Expand Up @@ -195,7 +195,7 @@ def execute(self, context: LaunchContext) -> Optional[List[Action]]:
('file', self.__file),
('xml_string', self.__xml_string),
('topic', self.__topic),
('name', self.__name),
('entity_name', self.__entity_name),
('allow_renaming', self.__allow_renaming),
('x', self.__x),
('y', self.__y),
Expand Down

0 comments on commit 9fae54b

Please sign in to comment.