ocra-recipes
Doxygen documentation for the ocra-recipes repository
XmlUtilities.h
Go to the documentation of this file.
1 #ifndef OCRA_UTIL_XML_UTILITIES
2 #define OCRA_UTIL_XML_UTILITIES
3 
4 #include <tinyxml.h>
5 #include <vector>
6 
7 namespace ocra {
8  namespace util {
9 
10 
11 
12 
13 inline std::string getDisplacementArgs(TiXmlElement* xmlElem)
14 {
15  std::string dispString;
16 
17  if(xmlElem != NULL)
18  {
19  std::vector<std::string> dispAttributes;
20 
21  dispAttributes.push_back("x");
22  dispAttributes.push_back("y");
23  dispAttributes.push_back("z");
24  dispAttributes.push_back("qw");
25  dispAttributes.push_back("qx");
26  dispAttributes.push_back("qy");
27  dispAttributes.push_back("qz");
28 
29  for (auto attribute : dispAttributes)
30  {
31  bool haveAlreadyFoundValue = false;
32  for (TiXmlAttribute* xmlAttrib=xmlElem->FirstAttribute(); xmlAttrib != NULL; xmlAttrib = xmlAttrib->Next())
33  {
34  if ( (attribute == xmlAttrib->Name()) && (!haveAlreadyFoundValue) )
35  {
36  dispString += xmlAttrib->Value();
37  dispString += " ";
38  haveAlreadyFoundValue = true;
39  }
40  }
41  if (!haveAlreadyFoundValue) {
42  std::string fallbackString = "0.0 ";
43  if (attribute == "qw") {
44  fallbackString = "1.0 ";
45  }
46  dispString += fallbackString;
47  }
48  }
49 
50  }
51 
52  return dispString;
53 }
54 
55 
56  } // namespace util
57 } // namespace ocra
58 #endif // OCRA_UTIL_XML_UTILITIES
Optimization-based Robot Controller namespace. a library of classes to write and solve optimization p...
std::string getDisplacementArgs(TiXmlElement *xmlElem)
Definition: XmlUtilities.h:13