31 #include <console_bridge/console.h>
44 auto m = std::make_shared<tesseract_scene_graph::JointMimic>();
46 std::throw_with_nested(std::runtime_error(
"Mimic: Missing or failed to parse mimic attribute 'joint'!"));
48 if (xml_element->Attribute(
"offset") ==
nullptr && xml_element->Attribute(
"multiplier") ==
nullptr)
49 CONSOLE_BRIDGE_logDebug(
"Mimic: Missing attribute 'offset' and 'multiplier', using default value 0 and 1!");
50 else if (xml_element->Attribute(
"offset") !=
nullptr && xml_element->Attribute(
"multiplier") ==
nullptr)
51 CONSOLE_BRIDGE_logDebug(
"Mimic: Missing attribute 'multiplier', using default value 1!");
52 else if (xml_element->Attribute(
"offset") ==
nullptr && xml_element->Attribute(
"multiplier") !=
nullptr)
53 CONSOLE_BRIDGE_logDebug(
"Mimic: Missing attribute 'offset', using default value 1!");
55 int s = xml_element->QueryDoubleAttribute(
"offset", &(m->offset));
56 if (s != tinyxml2::XML_NO_ATTRIBUTE && s != tinyxml2::XML_SUCCESS)
57 std::throw_with_nested(std::runtime_error(
"Mimic: Error parsing attribute 'offset'!"));
59 s = xml_element->QueryDoubleAttribute(
"multiplier", &(m->multiplier));
60 if (s != tinyxml2::XML_NO_ATTRIBUTE && s != tinyxml2::XML_SUCCESS)
61 std::throw_with_nested(std::runtime_error(
"Mimic: Error parsing attribute 'multiplier'!"));
66 tinyxml2::XMLElement*
writeMimic(
const std::shared_ptr<const tesseract_scene_graph::JointMimic>& mimic,
67 tinyxml2::XMLDocument& doc)
70 std::throw_with_nested(std::runtime_error(
"Mimic Joint is nullptr and cannot be converted to XML"));
73 xml_element->SetAttribute(
"joint", mimic->joint_name.c_str());
74 xml_element->SetAttribute(
"offset",
toString(mimic->offset).c_str());
75 xml_element->SetAttribute(
"multiplier",
toString(mimic->multiplier).c_str());