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

Revision history [back]

click to hide/show revision 1
initial version

Yep, you're on the right track. I had to do this for one of my projects a while back ( https://github.com/trainman419/dagny_robomagellan/blob/master/goal_list/src/goal_list.cpp#L143-L167 ):

 // load goal list from parameter server
 XmlRpc::XmlRpcValue xml_goals;
 n.getParam("goals", xml_goals);
 if( xml_goals.getType() != XmlRpc::XmlRpcValue::TypeArray ) {
    ROS_ERROR("param 'goals' is not a list");
 } else {
    for( int i=0; i<xml_goals.size(); ++i ) {
       if( xml_goals[i].getType() != XmlRpc::XmlRpcValue::TypeArray ) {
          ROS_ERROR("goals[%d] is not a list", i);
       } else {
          if( xml_goals[i].size() != 2 ) {
             ROS_ERROR("goals[%d] is not a pair", i);
          } else if( 
           xml_goals[i][0].getType() != XmlRpc::XmlRpcValue::TypeDouble ||
           xml_goals[i][1].getType() != XmlRpc::XmlRpcValue::TypeDouble ) {
             ROS_ERROR("goals[%d] is not a pair of doubles", i);
          } else {
             double a = xml_goals[i][0];
             double b = xml_goals[i][1];
          }
       }
    }
 }