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

Params appear broken in ROS2?

asked 2019-07-08 00:45:12 -0600

actinium226 gravatar image

According to https://index.ros.org/doc/ros2/Tutori..., if I have a properly formatted parameters yaml file, and I call ros2 run with __params:= pointing to that file, I should see the parameters defined in that file listed when I run ros2 param list, correct?

I'm doing this, but the only parameter I see when running that command is use_sim_time, which appears whether or not I pass the parameters.

The parameter file is getting parsed, I know this because if I don't have ros__parameters in there or some other inappropriate syntax it will complain and exit without running the node.

I'm on Ubuntu 18.04 on ROS Dashing. Is there any other useful info about my setup that I could provide?

I'm also a little confused on the expected node name within the parameters file. Does it need to match exactly the node name I provide when I call ros2 run? That is what I've been doing, but it doesn't seem to make any difference.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2019-07-08 07:34:21 -0600

I should see the parameters defined in that file listed when I run ros2 param list, correct?

Not necessarily. ROS 2 parameters machinery is slightly different from ROS 1 and in your case I guess that the main difference that you have to be aware of is that parameters have to de 'declared'. See for instance the list_parameters.cpp demo, or e.g.

node->declare_parameter("foo");

Without this bit, the foo parameter from your yaml file will not be loaded and that's probably your issue at the moment. It is still parsed, as you verified yourself, but still not loaded as you'd expect.

If it happened that you can't know all of the parameters beforehand, then you can pass a particular config when instantiating your node so that it allow_undeclared_parameters. See an example at the parameter_blackboard.cpp demo.

Notice that the same functionality exists in Python (rclpy) too.

I'm also a little confused on the expected node name within the parameters file
Does it need to match exactly the node name I provide

Yes, the node name in the yaml file should match the name of your node, e.g. "parameter_blackboard" in the parameter_blackboard.cpp demo.

edit flag offensive delete link more

Comments

Aha, that was it. I enabled allow_undeclared_parameters and that got it going. I'll make a PR against the parameters documentation to mention this. Thanks for the help.

actinium226 gravatar image actinium226  ( 2019-07-08 12:59:04 -0600 )edit

Thanks, I updated that tutorial to use parameter_blackboard specificially, which sets those settings, but didn't really mention why I guess. A pr would be awesome! In a previous version (Crystal and earlier) you could do what you described, and that demo just used talker, which has no special configurations.

William gravatar image William  ( 2019-07-08 14:31:09 -0600 )edit
actinium226 gravatar image actinium226  ( 2019-07-08 17:54:06 -0600 )edit

I am having exactly same issue when passing a yaml file to a node using launch.py. If I use rclpy for my node, how to set allow_undeclared_parameters ?

kyubot gravatar image kyubot  ( 2022-03-29 04:39:59 -0600 )edit

Question Tools

3 followers

Stats

Asked: 2019-07-08 00:45:12 -0600

Seen: 2,579 times

Last updated: Jul 08 '19