Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

You can see the Retrieving lists section in the end of this page http://wiki.ros.org/roscpp/Overview/Parameter%20Server.

For your specific case, I think it's better if you can format your yaml file like :

list:
 - id: 0 
   name: john 
   pos: [0,0,0]

 - id: 1 
   name: anna 
   pos: [0,0,0]

This way you can easily access the values as a dictionary after you fetch each item in the list as a XmlRpc::XmlRpcValue data type.

for (int i = 0; i < list.size(); i++) {
      XmlRpc::XmlRpcValue sublist = list[i];
      id=sublist["id"];
}

This is just a raw example, you should always check for format errors before fetching data to avoid crashing your program. This is the best way that I know of, if anyone else can offer a better alternative, I'll be happy to learn.