ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
1

ros2 param namespace

asked 2021-12-09 09:39:36 -0500

IanCol gravatar image

In this document: https://docs.ros.org/en/foxy/Concepts...

It mentions the following

Parameters are addressed by node name, node namespace, parameter name, and parameter namespace. Providing a parameter namespace is optional.

What exactly is a "parameter namespace"? I can't seem to find any other references to a parameter namespace in ros2.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2022-01-31 04:46:03 -0500

philipp_glira gravatar image

A parameter namespace can be set when declaring a new parameter, e.g. in Python:

self.declare_parameters(
    namespace="ns",
    parameters=[("bar", "default_value")],
)

You can then get a parameter in this namespace with:

bar = self.get_parameter("ns.bar")

The namespace can also be seen as parameter prefix, thus all parameter within a specific namespace can be retrieved with:

ns_params = self.get_parameters_by_prefix("ns")
edit flag offensive delete link more

Comments

Thanks! I actually forgot I had asked this question. At the time I believe I was confused about why you'd need parameter namespace in addition to the node namespace. I guess it's just another option for organizing node parameters in ROS2. Here's the CPP docs for the same declare_parameters function in case anyone is interested: https://docs.ros2.org/foxy/api/rclcpp... It has some detail on parameter namespaces.

IanCol gravatar image IanCol  ( 2022-02-10 15:24:43 -0500 )edit

Question Tools

3 followers

Stats

Asked: 2021-12-09 09:39:36 -0500

Seen: 1,390 times

Last updated: Dec 09 '21