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

Thanks to both! I did not think about XmlRpc and the hint of using the iterator works like a charm!

This is the code for the example above:

std::vector<std::string> fields;  // stores the field names
XmlRpc::XmlRpcValue list;

if (!node_handle_.getParam("/field_a", list)) {
  ROS_ERROR("Can't find '/field_a' in the YAML configuration file.");
  return;
}

for (auto it = list.begin(); it != list.end(); it++) {
  fields.push_back(it->first);
}

For the sake of completeness it->second is the the nested list {field_b1, field_b2, ..., field_bM}.

Thanks to both! I did not think about XmlRpc XmlRpc and the hint of using the iterator works like a charm!

This is the code for the example above:

std::vector<std::string> fields;  // stores the field names
XmlRpc::XmlRpcValue list;

if (!node_handle_.getParam("/field_a", list)) {
  ROS_ERROR("Can't find '/field_a' in the YAML configuration file.");
  return;
}

for (auto it = list.begin(); it != list.end(); it++) {
  fields.push_back(it->first);
}

For the sake of completeness it->second is the the nested list {field_b1, field_b2, ..., field_bM}.

Thanks to both! I did not think about XmlRpc and the hint of using the iterator works like a charm!

This is the code for the example above:

std::vector<std::string> fields;  // stores the field names
field_names;
XmlRpc::XmlRpcValue list;

if (!node_handle_.getParam("/field_a", list)) {
  ROS_ERROR("Can't find '/field_a' in the YAML configuration file.");
  return;
}

for (auto it = list.begin(); it != list.end(); it++) {
  fields.push_back(it->first);
field_names.push_back(it->first);
}

For the sake of completeness it->second is the the nested list {field_b1, field_b2, ..., field_bM}.