lists on the parameter server

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

lists on the parameter server

Armin Hornung
Hi!

Does anyone have a quick example on how to retrieve lists from the
parameter server? Suppose I want to store sets of <x,y,theta> values
(any amount) in parameters. Does the param file look correct like this?

----
coords/x: [0.0, 0.0, 0.2, 0.15]
coords/y: [0.0, 0.1, 0.0, 0.1]
coords/theta: [0.0, 0.0, -0.1, 0.1]
----

I would then retrieve the three lists, check if they are of the same
length, and create n (=4 here) tuples of <x,y,theta> out of them.

Is there any documentation available on how to retrieve these lists in
roscpp?
http://www.ros.org/wiki/roscpp/Overview/Parameter%20Server points to
http://xmlrpcpp.sourceforge.net/doc/classXmlRpc_1_1XmlRpcValue.html for
lists, but a quick example (or a pointer to how it is used in another
ROS node) would be nice to get started.

Thanks,
Armin

--
Armin Hornung                              Albert-Ludwigs-Universität
www.informatik.uni-freiburg.de/~hornunga   Dept. of Computer Science
[hidden email]        Humanoid Robots Lab
Tel.: +49 (0)761-203-8010                  Georges-Köhler-Allee 79
Fax : +49 (0)761-203-8007                  D-79110 Freiburg, Germany

_______________________________________________
ros-users mailing list
[hidden email]
https://code.ros.org/mailman/listinfo/ros-users
Reply | Threaded
Open this post in threaded view
|

Re: lists on the parameter server

Jeremy Leibs
On Mon, May 31, 2010 at 7:37 AM, Armin Hornung
<[hidden email]> wrote:

> Is there any documentation available on how to retrieve these lists in
> roscpp?
> http://www.ros.org/wiki/roscpp/Overview/Parameter%20Server points to
> http://xmlrpcpp.sourceforge.net/doc/classXmlRpc_1_1XmlRpcValue.html for
> lists, but a quick example (or a pointer to how it is used in another
> ROS node) would be nice to get started.
>

The XmlRpcValue type implements the reinterpret cast operator for most
types.  Unfortunately, almost all but the most explicit usages are
ambiguously defined, so you often need to be explicit.  But, generally
speaking, it means you can just treat the XmlRpcValue object as the
type you want it to be.  In this case, assuming the XmlRpcValue is a
list, then you can simply use operator[] to access members, and then
cast them as the appropriate type.  The following example retrieves a
list of doubles from the param server and sums them:


#include <iostream>
#include "ros/ros.h"

int main(int argc, char** argv)
{
  ros::init(argc, argv, "my_node");
  ros::NodeHandle nh;

  XmlRpc::XmlRpcValue x;

  nh.getParam("my_list", x);

  assert(x.getType() == XmlRpc::XmlRpcValue::TypeArray);

  double sum = 0.0;
  for (int i = 0; i < x.size(); i++)
  {
    sum += (double)(x[i]);
  }

}
_______________________________________________
ros-users mailing list
[hidden email]
https://code.ros.org/mailman/listinfo/ros-users
Reply | Threaded
Open this post in threaded view
|

Re: lists on the parameter server

Armin Hornung
In reply to this post by Armin Hornung
Hi Jeremy,

> The XmlRpcValue type implements the reinterpret cast operator for most
> types.  Unfortunately, almost all but the most explicit usages are
> ambiguously defined, so you often need to be explicit.  But, generally
> speaking, it means you can just treat the XmlRpcValue object as the
> type you want it to be.  In this case, assuming the XmlRpcValue is a
> list, then you can simply use operator[] to access members, and then
> cast them as the appropriate type.  The following example retrieves a
> list of doubles from the param server and sums them:
[...]

Thanks, that works great! Should that example be part of the roscpp
param server wiki page? It's a nice starting point when working with
parameter lists and surely helps more than the plain XmlRpc documentation.


Cheers,
Armin
--
Armin Hornung                              Albert-Ludwigs-Universität
www.informatik.uni-freiburg.de/~hornunga   Dept. of Computer Science
[hidden email]        Humanoid Robots Lab
Tel.: +49 (0)761-203-8010                  Georges-Köhler-Allee 79
Fax : +49 (0)761-203-8007                  D-79110 Freiburg, Germany
_______________________________________________
ros-users mailing list
[hidden email]
https://code.ros.org/mailman/listinfo/ros-users
Reply | Threaded
Open this post in threaded view
|

Re: lists on the parameter server

Josh Faust


Thanks, that works great! Should that example be part of the roscpp
param server wiki page? It's a nice starting point when working with
parameter lists and surely helps more than the plain XmlRpc documentation.


I've added it to the roscpp overview's parameter server page: http://www.ros.org/wiki/roscpp/Overview/Parameter%20Server

Josh

_______________________________________________
ros-users mailing list
[hidden email]
https://code.ros.org/mailman/listinfo/ros-users