Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adapt to '--ros-args ... [--]'-based ROS args extraction #52

Merged
merged 3 commits into from
Aug 7, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions launch_ros/launch_ros/actions/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ def __init__(
cmd += [] if arguments is None else arguments
# Reserve space for ros specific arguments.
# The substitutions will get expanded when the action is executed.
cmd += ['--ros-args'] # Prepend ros specific arguments with --ros-args flag
if node_name is not None:
cmd += [LocalSubstitution(
"ros_specific_arguments['name']", description='node name')]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,5 @@ def test_push_ros_namespace(config):
node_namespace=config.node_ns,
)
node._perform_substitutions(lc)
expected_cmd_len = 2 if config.expected_ns is not None else 1
assert expected_cmd_len == len(node.cmd)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should have been updated to:

    expected_cmd_len = 3 if config.expected_ns is not None else 2
    assert expected_cmd_len == len(node.cmd)

Checking that __ns:=/ is not added when the expanded namespace is '' is important.

Copy link
Contributor Author

@hidmic hidmic Aug 9, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The thing is that the original test was incorrect, as node.cmd substitutions are not resolved by node._perform_substitutions().

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The len of the list is the same before and after performing the substitutions, so it was ok correct.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The len of the list is the same before and after performing the substitutions

That is a result of the current implementation, and thus not guaranteed nor enforced by the API.

Checking that __ns:=/ is not added when the expanded namespace is '' is important.

I agree with this, but the former test was not adequate for said purpose. We can change either launch_ros.actions.Node implementation or the test itself to query the fully resolved cmd instead of counting substitutions and expecting them to be right.

expected_ns = config.expected_ns if config.expected_ns is not None else ''
assert expected_ns == node.expanded_node_namespace