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

ROS2: how to specify parameter with namespace in python launch file?

asked 2022-01-31 04:27:44 -0500

philipp_glira gravatar image

It is unclear to me how a parameter with namespace is accessed in a python launch file.

I define a parameter in my node with:

self.declare_parameters(
    namespace="ns1",
    parameters=[("bar", "default_value_bar_ns1")],
)

In my python launch file I'm trying to set a new value for this parameter with:

parameters=[
    {
        "ns1.bar": "new_value_bar_ns1", # this does not work!
    }
],

With this the parameter "bar" in namespace "ns1" remains unchanged.

What am I doing wrong? Thanks in advance.

Minimal working example here: https://github.com/pglira/ros2-answer...

I'm using ROS2 galactic with the official docker image "ros:galactic".

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2022-02-10 17:58:50 -0500

guru_florida gravatar image

updated 2022-02-10 17:59:22 -0500

I've run into the same issue and I've submitted a githib issue. I adapted some of your code (see my github gist) and figured out that if you change your declare_parameters() syntax to the following it works as expected. It does indeed seem like a bug:

self.declare_parameters(
    namespace="",
    parameters=[("ns1.bar", "default_value_bar_ns1")],
)

I'll follow up when the issue is resolved.

edit flag offensive delete link more

Question Tools

3 followers

Stats

Asked: 2022-01-31 04:27:44 -0500

Seen: 861 times

Last updated: Feb 10 '22