utils.cpp
Go to the documentation of this file.
1 
26 #include <tesseract_srdf/utils.h>
30 
31 namespace tesseract_srdf
32 {
34 {
35  for (const auto& pair : srdf_model.acm.getAllAllowedCollisions())
36  scene_graph.addAllowedCollision(pair.first.first, pair.first.second, pair.second);
37 }
38 
39 bool compareLinkPairAlphabetically(std::reference_wrapper<const tesseract_common::LinkNamesPair> pair1,
40  std::reference_wrapper<const tesseract_common::LinkNamesPair> pair2)
41 {
42  // Sort first by the first string
43  if (pair1.get().first != pair2.get().first)
44  {
45  return pair1.get().first < pair2.get().first;
46  }
47 
48  // Then sort by the second
49  return pair1.get().second < pair2.get().second;
50 }
51 
52 std::vector<std::reference_wrapper<const tesseract_common::LinkNamesPair>>
54 {
55  std::vector<std::reference_wrapper<const tesseract_common::LinkNamesPair>> acm_keys;
56  acm_keys.reserve(allowed_collision_entries.size());
57  for (const auto& acm_pair : allowed_collision_entries)
58  {
59  acm_keys.push_back(std::ref(acm_pair.first));
60  }
61 
62  // Sort the keys alphabetically
63  sort(acm_keys.begin(), acm_keys.end(), compareLinkPairAlphabetically);
64 
65  return acm_keys;
66 }
67 
68 } // namespace tesseract_srdf
graph.h
tesseract_srdf
Main namespace.
Definition: collision_margins.h:43
allowed_collision_matrix.h
tesseract_common::AllowedCollisionMatrix::getAllAllowedCollisions
const AllowedCollisionEntries & getAllAllowedCollisions() const
tesseract_common::AllowedCollisionEntries
std::unordered_map< tesseract_common::LinkNamesPair, std::string, tesseract_common::PairHash > AllowedCollisionEntries
tesseract_scene_graph::SceneGraph::addAllowedCollision
void addAllowedCollision(const std::string &link_name1, const std::string &link_name2, const std::string &reason)
tesseract_scene_graph::SceneGraph
tesseract_srdf::SRDFModel
Representation of semantic information about the robot.
Definition: srdf_model.h:54
utils.h
Tesseract SRDF utility functions.
tesseract_srdf::SRDFModel::acm
tesseract_common::AllowedCollisionMatrix acm
The allowed collision matrix.
Definition: srdf_model.h:106
tesseract_srdf::getAlphabeticalACMKeys
std::vector< std::reference_wrapper< const tesseract_common::LinkNamesPair > > getAlphabeticalACMKeys(const tesseract_common::AllowedCollisionEntries &allowed_collision_entries)
Returns an alphabetically sorted vector of ACM keys (the link pairs)
Definition: utils.cpp:53
tesseract_srdf::processSRDFAllowedCollisions
void processSRDFAllowedCollisions(tesseract_scene_graph::SceneGraph &scene_graph, const SRDFModel &srdf_model)
Add allowed collisions to the scene graph.
Definition: utils.cpp:33
srdf_model.h
Parse srdf xml.
tesseract_srdf::compareLinkPairAlphabetically
bool compareLinkPairAlphabetically(std::reference_wrapper< const tesseract_common::LinkNamesPair > pair1, std::reference_wrapper< const tesseract_common::LinkNamesPair > pair2)
Used to sort a pair of strings alphabetically - first by the pair.first and then by pair....
Definition: utils.cpp:39


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