Ask Your Question
1

Private Parameters in a sub namespace

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

Crusty gravatar image

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

Hello,

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?

Thanks!

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" />
</node>

But I do need to set this parameter via commandline.

edit retag flag offensive close merge delete

Comments

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 imagegvdhoorn ( 2015-09-03 13:03:32 -0500 )edit

Typo only local to this post, fixed thanks.

Crusty gravatar imageCrusty ( 2015-09-03 14:11:28 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
3

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

ahendrix gravatar image

Try:

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

Comments

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

Crusty gravatar imageCrusty ( 2015-09-03 12:16:34 -0500 )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 imageahendrix ( 2015-09-03 13:07:08 -0500 )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 imageCrusty ( 2015-09-03 14:13:26 -0500 )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 imageCrusty ( 2015-09-04 05:35:04 -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

1 follower

Stats

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

Seen: 1,311 times

Last updated: Sep 03 '15