Skip to content

Commit

Permalink
Force explicit --ros-args in cli args. (#416)
Browse files Browse the repository at this point in the history
Signed-off-by: Michel Hidalgo <[email protected]>
  • Loading branch information
hidmic authored Sep 5, 2019
1 parent a320fb9 commit c8e53e0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
6 changes: 2 additions & 4 deletions rclpy/rclpy/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,8 @@ def __init__(
:param context: The context to be associated with, or ``None`` for the default global
context.
:param cli_args: A list of strings of command line args to be used only by this node.
Being specific to a ROS node, an implicit `--ros-args` scope flag always precedes
these arguments.
These arguments are used to extract remappings used by the node and other ROS specific
settings, as well as user defined non-ROS arguments.
:param namespace: The namespace to which relative topic and service names will be prefixed.
Validated by :func:`validate_namespace`.
:param use_global_arguments: ``False`` if the node should ignore process-wide command line
Expand Down Expand Up @@ -146,8 +146,6 @@ def __init__(
self._parameter_overrides = {}
self._descriptors = {}

if cli_args is not None and '--ros-args' not in cli_args:
cli_args = ['--ros-args', *cli_args]
namespace = namespace or ''
if not self._context.ok():
raise NotInitializedException('cannot create node')
Expand Down
6 changes: 5 additions & 1 deletion rclpy/test/test_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -1550,7 +1550,11 @@ def test_node_arguments(self):
rclpy.init(context=context)
try:
node = rclpy.create_node(
'my_node', namespace='/my_ns', cli_args=['-r', '__ns:=/foo/bar'], context=context)
'my_node',
namespace='/my_ns',
cli_args=['--ros-args', '-r', '__ns:=/foo/bar'],
context=context
)
self.assertEqual('/foo/bar', node.get_namespace())
node.destroy_node()
finally:
Expand Down

0 comments on commit c8e53e0

Please sign in to comment.