[c++] rosparam server : How to transform a set of parameters of type XmlRpc::XmlRpcValue into some multi-type dictionnary or array ?
Hello,
When doing rosparam list
in a shell while an instance of ros is running, I get a list of "keys" or paths, e.g :
/ros/family/a/a_first_param
/ros/family/b/b_first_param
/ros/family/b/b_second_param
/ros/family/b/b_third_param
/ros/family/c/c_first_param
/ros/family/c/c_second_param
Now as explained here http://wiki.ros.org/Parameter%20Server it seems to be possible to fetch a dictionnary if we rosparam get /ros/family
which would be displayed into console as if it was written respecting the .yaml indentations. In this case the console output would be :
{
a : {a_first_param : somevalue},
b : {b_first_param : somevalue, b_second_param : somevalue, b_third_param : somevalue},
c : {c_first_param : somevalue, c_second_param : somevalue}
}
I suspect this output to be of type XmlRpc::XmlRpcValue
. Besides, this output would have that .yaml file as an equivalent :
family:
a:
a_first_param: somevalue #int
b:
b_first_param: somevalue #double
b_second_param: somevalue #string
b_third_param: somevalue #boolean
c:
c_first_param: somevalue #list
c_second_param: somevalue
Finally, let's say I am actually only interested in the parameters associated to b
, but I cannot prevent the whole family to be loaded on the parameter server. Then I would like to create a function which reads this bunch of parameters and returns only those associated to b
. Furthermore, these parameters' names aren't known in advance, and neither the number of these, and neither their value.
I would ideally like the output to be a multi-type dictionary, which, as far as I know, doesn't exist in c++. So a struct or an [n rows, 2 columns] array would suit me, as long as I am then able to find back the name of the attributes and their value in order to tweak those same parameters. (Preferably by replacing the whole set, but it will still be feasible individually, so less worries for that.)
So my c++ snippet looks like that :
<namespace::WhichType?> getParameters();
{
XmlRpc::XmlRpcValue parameters;
if (ros::param::get("ros/family", parameters))
return parameters.structFromXml(); // or .arrayFromXml()
else
ROS_WARN("blabla");
}
Unfortunately, this dochttp://xmlrpcpp.sourceforge.net/doc/c... indicates that prototype for .structFromXml()
:
bool structFromXml (std::string const &valueXml, int *offset)
So what is valueXml
? Is it the path "ros/family"
? Is it the outputed variable that will contains either my struct or array ? What should I put as 2nd argument (about the offset) please ?
Regards