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

Private Parameters in a sub namespace

asked 2015-09-03 11:16:39 -0600

Crusty gravatar image

updated 2015-09-03 14:10:21 -0600


I have a ROS node that essentially does this:

      ros::NodeHandle nh("~");
      ros::NodeHandle node_handle(nh, "derp"),
      node_handle.param<double>("rate", rate, 10.0);

Which means that the private parameter "rate" is pushed down into a namespace like so: derp/rate

I want to run aforementioned node from the command line and set this private parameter, but I do get errors. If the parameter were not in a sub namespace i could just launch the node by

rosrun mypack mynode _rate:=100

Running the node via rosrun mypack mynode derp/_rate:=100

Fails with a graph error. How can I set this private parameter via commandline?


Edit: running this with a launch file like so works:

<node name="mynode" pkg="mypack" type="mynode" output="screen"">
    <param name="derp/rate" value="100.0" />

But I do need to set this parameter via commandline.

edit retag flag offensive close merge delete


Just to make sure: the _hz suffix is only in your launch file example, not any of the command lines. Your C++ excerpt also doesn't show it. Are these the same nodes?

gvdhoorn gravatar image gvdhoorn  ( 2015-09-03 13:03:32 -0600 )edit

Typo only local to this post, fixed thanks.

Crusty gravatar image Crusty  ( 2015-09-03 14:11:28 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2015-09-03 11:55:54 -0600

ahendrix gravatar image


 rosrun mypack mynode _derp/rate:=100
edit flag offensive delete link more


Tested, sadly doesnt work, node still running at 10Hz :(

Crusty gravatar image Crusty  ( 2015-09-03 12:16:34 -0600 )edit

When I run a node with that syntax, it correctly sets the parameter. Are you sure you didn't make a typo in the parameter name?

ahendrix gravatar image ahendrix  ( 2015-09-03 13:07:08 -0600 )edit

Yep, it was just a copy paste error to here. I tried reducing and simplifying the example to the essence for the sake of posting it here distraction-free. The topic is indeed called rate_hz everywhere in my code.

Crusty gravatar image Crusty  ( 2015-09-03 14:13:26 -0600 )edit

I tested this again today, and it works, thanks. I added some debugging statements, and turns out the rate got set correctly, but the publishing speed was still always at 10 Hz. So I concluded it didn't work. The slow publishing had other reasons in the code I am working with.

Crusty gravatar image Crusty  ( 2015-09-04 05:35:04 -0600 )edit

Question Tools

1 follower


Asked: 2015-09-03 11:16:39 -0600

Seen: 2,590 times

Last updated: Sep 03 '15