Ask Your Question
0

Params appear broken in ROS2?

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

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 -0500

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 imageactinium226 ( 2019-07-08 12:59:04 -0500 )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 imageWilliam ( 2019-07-08 14:31:09 -0500 )edit
actinium226 gravatar imageactinium226 ( 2019-07-08 17:54:06 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

2 followers

Stats

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

Seen: 77 times

Last updated: Jul 08