disabled_collisions.cpp
Go to the documentation of this file.
1 
29 #include <console_bridge/console.h>
30 #include <tinyxml2.h>
32 
33 #include <tesseract_common/utils.h>
37 
38 namespace tesseract_srdf
39 {
41  const tinyxml2::XMLElement* srdf_xml,
42  const std::array<int, 3>& /*version*/)
43 {
45 
46  for (const tinyxml2::XMLElement* xml_element = srdf_xml->FirstChildElement("disable_collisions");
47  xml_element != nullptr;
48  xml_element = xml_element->NextSiblingElement("disable_collisions"))
49  {
50  std::string link1_name, link2_name, reason;
51  int status = tesseract_common::QueryStringAttributeRequired(xml_element, "link1", link1_name);
52  if (status != tinyxml2::XML_SUCCESS)
53  std::throw_with_nested(std::runtime_error("DisabledCollisions: Missing or failed to parse attribute 'link1'!"));
54 
55  status = tesseract_common::QueryStringAttributeRequired(xml_element, "link2", link2_name);
56  if (status != tinyxml2::XML_SUCCESS)
57  std::throw_with_nested(std::runtime_error("DisabledCollisions: Missing or failed to parse attribute 'link2'!"));
58 
59  if (!scene_graph.getLink(link1_name))
60  {
61  CONSOLE_BRIDGE_logWarn("Link '%s' is not known to URDF. Cannot disable collisons.", link1_name.c_str());
62  continue;
63  }
64  if (!scene_graph.getLink(link2_name))
65  {
66  CONSOLE_BRIDGE_logWarn("Link '%s' is not known to URDF. Cannot disable collisons.", link2_name.c_str());
67  continue;
68  }
69 
70  status = tesseract_common::QueryStringAttribute(xml_element, "reason", reason);
71  // LCOV_EXCL_START
72  if (status != tinyxml2::XML_NO_ATTRIBUTE && status != tinyxml2::XML_SUCCESS)
73  std::throw_with_nested(std::runtime_error("DisabledCollisions: Missing or failed to parse attribute 'reason'!"));
74  // LCOV_EXCL_STOP
75 
76  acm.addAllowedCollision(link1_name, link2_name, reason);
77  }
78 
79  return acm;
80 }
81 } // namespace tesseract_srdf
graph.h
tesseract_srdf
Main namespace.
Definition: collision_margins.h:43
tesseract_common::QueryStringAttributeRequired
int QueryStringAttributeRequired(const tinyxml2::XMLElement *xml_element, const char *name, std::string &value)
allowed_collision_matrix.h
utils.h
TESSERACT_COMMON_IGNORE_WARNINGS_PUSH
#define TESSERACT_COMMON_IGNORE_WARNINGS_PUSH
tesseract_scene_graph::SceneGraph
disabled_collisions.h
Parse disabled collision data from srdf file.
tesseract_common::QueryStringAttribute
int QueryStringAttribute(const tinyxml2::XMLElement *xml_element, const char *name, std::string &value)
tesseract_srdf::parseDisabledCollisions
tesseract_common::AllowedCollisionMatrix parseDisabledCollisions(const tesseract_scene_graph::SceneGraph &scene_graph, const tinyxml2::XMLElement *srdf_xml, const std::array< int, 3 > &version)
Parse allowed collisions from srdf xml element.
Definition: disabled_collisions.cpp:40
TESSERACT_COMMON_IGNORE_WARNINGS_POP
#define TESSERACT_COMMON_IGNORE_WARNINGS_POP
tesseract_common::AllowedCollisionMatrix
tesseract_common::AllowedCollisionMatrix::addAllowedCollision
virtual void addAllowedCollision(const std::string &link_name1, const std::string &link_name2, const std::string &reason)
tesseract_scene_graph::SceneGraph::getLink
std::shared_ptr< const Link > getLink(const std::string &name) const
macros.h


tesseract_srdf
Author(s): Levi Armstrong
autogenerated on Sun May 18 2025 03:02:04