1#ifndef TESSERACT_URDF_COMMON_UNIT_H
2#define TESSERACT_URDF_COMMON_UNIT_H
10#include <gtest/gtest.h>
11#include <console_bridge/console.h>
20template <
typename ElementType>
22 std::function<ElementType(
const tinyxml2::XMLElement*,
const int)> func,
24 const std::string& element_name,
30 tinyxml2::XMLElement*
element =
xml_doc.FirstChildElement(element_name.c_str());
37 catch (
const std::exception& e)
46template <
typename ElementType>
52 const std::string& element_name,
60 tinyxml2::XMLElement*
element =
xml_doc.FirstChildElement(element_name.c_str());
67 catch (
const std::exception& e)
76template <
typename ElementType>
81 const std::string& element_name,
88 tinyxml2::XMLElement*
element =
xml_doc.FirstChildElement(element_name.c_str());
95 catch (
const std::exception& e)
104template <
typename ElementType>
106 std::function<ElementType(
const tinyxml2::XMLElement*,
108 std::unordered_map<std::string, tesseract_scene_graph::Material::Ptr>&,
111 const std::string& element_name,
113 std::unordered_map<std::string, tesseract_scene_graph::Material::Ptr>&
available_materials,
119 tinyxml2::XMLElement*
element =
xml_doc.FirstChildElement(element_name.c_str());
126 catch (
const std::exception& e)
135template <
typename ElementType>
137 std::function<ElementType(
const tinyxml2::XMLElement*,
138 std::unordered_map<std::string, tesseract_scene_graph::Material::Ptr>&,
142 const std::string& element_name,
143 std::unordered_map<std::string, tesseract_scene_graph::Material::Ptr>&
available_materials,
150 tinyxml2::XMLElement*
element =
xml_doc.FirstChildElement(element_name.c_str());
157 catch (
const std::exception& e)
174 if (!in.empty() && in.back() ==
'\n')
175 out = in.substr(0, in.size() - 1);
186 tinyxml2::XMLPrinter printer;
188 std::stringstream ss;
189 ss << printer.CStr();
202template <
typename TessType>
204 std::function<tinyxml2::XMLElement*(
const TessType&, tinyxml2::XMLDocument&)> func,
207 tinyxml2::XMLDocument doc;
234template <
typename TessType>
236 std::function<tinyxml2::XMLElement*(
const TessType&, tinyxml2::XMLDocument&,
const std::string&)> func,
238 const std::string& directory)
240 tinyxml2::XMLDocument doc;
244 tinyxml2::XMLElement*
element = func(
type, doc, directory);
268template <
typename TessType>
272 tinyxml2::XMLElement*(
const TessType&, tinyxml2::XMLDocument&,
const std::string&,
const std::string&)> func,
274 const std::string& directory,
275 const std::string& filename)
277 tinyxml2::XMLDocument doc;
281 tinyxml2::XMLElement*
element = func(
type, doc, directory, filename);
306template <
typename TessType>
308 std::function<tinyxml2::XMLElement*(
const TessType&,
309 tinyxml2::XMLDocument&,
314 const std::string& directory,
315 const std::string& link_name,
318 tinyxml2::XMLDocument doc;
322 tinyxml2::XMLElement*
element = func(
type, doc, directory, link_name,
id);
Abstract class for resource loaders.
Definition: resource_locator.h:43
EXPECT_TRUE(tesseract_common::isIdentical< tesseract_collision::ObjectPairKey >(pairs, check_pairs, false))
#define TESSERACT_COMMON_IGNORE_WARNINGS_PUSH
Definition: macros.h:71
Definition: create_convex_hull.cpp:36
void printNestedException(const std::exception &e, int level=0)
Print a nested exception.
Definition: utils.cpp:193
Locate and retrieve resource data.
ResourceLocator::Ptr locator
Definition: resource_locator_unit.cpp:57
Common Tesseract Utility Functions.
mCollisionCheckConfig contact_request type
Definition: tesseract_environment_collision.cpp:103
tinyxml2::XMLElement * element
Definition: tesseract_srdf_unit.cpp:815
tesseract_common::fs::path path
Definition: tesseract_srdf_unit.cpp:1992
std::string xml_string
Definition: tesseract_srdf_unit.cpp:567
tinyxml2::XMLDocument xml_doc
Definition: tesseract_srdf_unit.cpp:812
Locate and retrieve resource data in tesseract_support.
TESSERACT_COMMON_IGNORE_WARNINGS_PUSH TESSERACT_COMMON_IGNORE_WARNINGS_POP bool runTest(ElementType &type, std::function< ElementType(const tinyxml2::XMLElement *, const int)> func, const std::string &xml_string, const std::string &element_name, int version)
Definition: tesseract_urdf_common_unit.h:21
std::string stripNewline(const std::string &in)
stripNewline - For some reason, tinyxml2 printers add a trailing newline. This function removes it.
Definition: tesseract_urdf_common_unit.h:171
int writeTest(TessType &type, std::function< tinyxml2::XMLElement *(const TessType &, tinyxml2::XMLDocument &)> func, std::string &text)
writeTest - test write functions
Definition: tesseract_urdf_common_unit.h:203
std::string toString(const tinyxml2::XMLElement *element)
Definition: tesseract_urdf_common_unit.h:181
void writeTextToFile(const std::string &path, const std::string &text)
Definition: tesseract_urdf_common_unit.h:337
std::unordered_map< std::string, tesseract_scene_graph::Material::Ptr > available_materials
Definition: tesseract_urdf_material_unit.cpp:20
A urdf parser for tesseract.