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

Use correct namespace when evaluating parameter files for composable nodes #303

Merged
merged 1 commit into from
Mar 17, 2022

Conversation

jacobperron
Copy link
Member

  • When resolving parameters from a file, use the full node namespace, combined with any base
    namespace provided by launch (e.g. from PushRosNamespace).
  • Handle edge case in 'to_parameters_list', when namespace equals '/'.
  • Fix bug in test fixture returning invalid node names that contain consecutive forward slashes.
  • Add tests to cover cases for loading parameters from file when namespace is provided by
    PushRosNamespace actions.

…nodes

* When resolving parameters from a file, use the full node namespace, combined with any base
  namespace provided by launch (e.g. from PushRosNamespace).
* Handle edge case in 'to_parameters_list', when namespace equals '/'.
* Fix bug in test fixture returning invalid node names that contain consecutive forward slashes.
* Add tests to cover cases for loading parameters from file when namespace is provided by
  PushRosNamespace actions.

Signed-off-by: Jacob Perron <jacob@openrobotics.org>
@jacobperron
Copy link
Member Author

jacobperron commented Mar 14, 2022

Testing packages above launch_ros:

  • Linux Build Status
  • Linux-aarch64 Build Status
  • Windows Build Status

@@ -293,16 +293,17 @@ def get_composable_node_load_request(
if parameters:
request.parameters = [
param.to_parameter_msg() for param in to_parameters_list(
context, request.node_name, expanded_ns,
context, request.node_name, combined_ns,
Copy link
Member Author

Choose a reason for hiding this comment

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

This is the main bug.

@@ -75,7 +75,7 @@ def to_parameters_list(
"""
parameters = [] # type: List[rclpy.parameter.Parameter]
node_name = node_name.lstrip('/')
if namespace:
if namespace and namespace != '/':
Copy link
Member Author

Choose a reason for hiding this comment

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

This handles an edge case where namespace == '/', which would result in a node name with a forward slash, e.g. /test_node_name. But, the rest of this function expects the slashes to be stripped.

if request.node_namespace == '/':
response.full_node_name = f'/{request.node_name}'
else:
response.full_node_name = f'{request.node_namespace}/{request.node_name}'
Copy link
Member Author

Choose a reason for hiding this comment

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

This change is to avoid illegal node names (containing two forward slashes, e.g. //test_node_name).

Copy link
Contributor

@adityapande-1995 adityapande-1995 left a comment

Choose a reason for hiding this comment

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

IIUC, the changes in test_launch_ros avoid illegal node names just for the test cases. What would happen if a user tries to pass illegal node names to launch_ros (other than the test cases that is) ?

@jacobperron
Copy link
Member Author

jacobperron commented Mar 16, 2022

IIUC, the changes in test_launch_ros avoid illegal node names just for the test cases. What would happen if a user tries to pass illegal node names to launch_ros (other than the test cases that is) ?

Specifically, the change avoids the mock component container from reporting an illegal node name. If a real-world container does this, then I guess it will result in similar issues loading parameters (silently ignore parameters that don't match the node name). For example, if a container loads a node and reports an invalid name "//foo", then the following parameter will, silently, not be passed to the node:

/foo
  ros__parameters:
    bar: 1

Maybe the following parameters file would work, but I didn't test it:

//foo
  ros__parameters:
    bar: 1

IMO, we shouldn't go out of our way to support unexpected node naming conventions. We could go so far as to validate node names reported by containers and emit a warning that there's a problem with the container being launched. That probably deserves it's own PR though.

Copy link
Member

@ivanpauno ivanpauno left a comment

Choose a reason for hiding this comment

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

LGTM!

@jacobperron jacobperron merged commit b0be1a1 into master Mar 17, 2022
@delete-merged-branch delete-merged-branch bot deleted the jacob/fix_composable_node_param_namespace branch March 17, 2022 22:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants