ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange |
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}
.
2 | No.2 Revision |
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}
.
3 | No.3 Revision |
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}
.