Skip to content

Pass node-specific params to a namespaced node #1306

Description

@ndahn

Operating System:

Linux 6.8.0-106-generic #106~22.04.1-Ubuntu

ROS version or commit hash:

jazzy

Steps to reproduce issue

  1. Create a file with the example code below
param_echo_node.py
#!/usr/bin/env python3
import rclpy
from rclpy.node import Node


class ParamEchoNode(Node):
    def __init__(self):
        super().__init__(
            "param_echo_node",
            allow_undeclared_parameters=True,
            automatically_declare_parameters_from_overrides=True,
        )

        params = [
            f"### [PARAM] {name} = {p.value!r}"
            for name, p in self.get_parameters_by_prefix("").items()
        ]
        self.get_logger().info("Params:\n" + "\n".join(params))


def main(args=None):
    rclpy.init(args=args)
    node = ParamEchoNode()
    rclpy.spin(node)
    rclpy.shutdown()


if __name__ == "__main__":
    main()
  1. Run it with
python param_echo_node.py --ros-args -r __ns:=/test -r __name:=echo -p echo:msg:=hi
  1. Note how the node does not have a msg param

Expected behavior

I expected the node to have a msg param.

Actual behavior

The node will have a msg param if either the namespace or the param prefix (echo:) is removed. I could not find a way to give the param a prefix that would assign it to the node in the presence of a namespace. This particular combination is also missing from all the documentation as well as the test cases.

It seems that dots and slashes are not accepted in the prefix or param name. Is there no way to pass a param to a specific namespaced node?

Additional information

The tests linked above have the following comment which might be related:

TODO(hidmic): restore tests (and drop the following ones) when parameter names
               are standardized to use slashes in lieu of dots.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions