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

listing parameters or using a dictionary

asked 2012-10-30 13:35:16 -0600

brice rebsamen gravatar image

updated 2014-01-28 17:14:06 -0600

ngrennan gravatar image

In C++, is there a way to list parameters on the parameter server, optionally those in a particular namespace? Alternatively, can I use a dictionary/map?

I want to put a mapping name/number in a yaml file loaded by roslaunch, and my node should be able to list the names and retrieve the associated number. rosparam list can do that, and associated with grep I can retrieve only the parameters I want. can I do that in C++ directly. the parameter server c++ API does not seem to provide that, or is it hidden? Can it be added in future releases?

I tried using a dictionary but it was expended in a list of parameters instead of being a dictionary data structure, i.e. those 2 yaml files yielded the same result

channel_numbers: {applanix: 0, radar: 1, trimble: 5, velodyne: 10}


  applanix: 0
  radar: 1
  trimble: 5
  velodyne: 10

I would like something like:

ros::NodeHandle nh("~");
vector<string> parameters = nh.list_parameters("channel_numbers");
// and then for each parameter in parameters get its value...
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2012-10-31 02:16:41 -0600

dornhege gravatar image

updated 2015-04-30 15:28:15 -0600

Dirk Thomas gravatar image

The functionality is there by using XmlRpcValue versions of the getParam functions.

An example of how to get a list is available: .

If you need more, i.e. dictionaries then refer to the XmlRpcValue docs.

TypeStruct is a dictionary. There is hidden functionality that the official docs do not list and afaik was added to ROS. For a dictionary there are begin() and end() functions that allow to iterate over the dict entries. You can find an example here:

edit flag offensive delete link more


The links end with a period accidentally. I don't have enough rep to edit.

gustavogoretkin gravatar image gustavogoretkin  ( 2015-04-30 14:48:01 -0600 )edit

I removed the dot.

Dirk Thomas gravatar image Dirk Thomas  ( 2015-04-30 15:28:34 -0600 )edit

Thank you so much for sharing the example from alufr-ros package ;)

smihael gravatar image smihael  ( 2015-08-18 07:57:03 -0600 )edit

Is there an updated link to the example. I couldn't find the TypeStruct example on the google code archive. I'm trying to print the params used by a given node.

blakejwc gravatar image blakejwc  ( 2018-04-17 09:09:18 -0600 )edit

Question Tools


Asked: 2012-10-30 13:35:16 -0600

Seen: 4,271 times

Last updated: Apr 30 '15