Collision Checker
fcl_collision_requests.cc
Go to the documentation of this file.
2 #include <utility>
5 
6 namespace collision {
7 namespace solvers {
8 namespace solverFCL {
9 
11  m_ResultPairs.emplace(o1, o2);
12 }
13 
15  std::list<int> list2) {
16  for (int el1 : list1) {
17  for (int el2 : list2) {
18  addRequestResultPair(el1, el2);
19  }
20  }
21 }
22 
23 std::set<std::pair<int, int>>
25  return m_ResultPairs;
26 }
27 
31  pair) {
32  auto &checked_pairs = checkedPairs;
33  auto search = checked_pairs.find(pair);
34  if (search != checked_pairs.end()) return false;
35 
36  checked_pairs.emplace(pair);
37 
38  return true;
39 }
40 
41 bool CollisionRequestDataMultipleObstacles::addRequestResultObstacleObject(
43  // todo: add a dedicated counter to optimize perfomance
44 
45  if (m_max_obstacles < 0) {
46  m_obstacles.push_back(obj);
47  return false;
48  } else {
49  if ((int)m_obstacles.size() < m_max_obstacles) {
50  m_obstacles.push_back(obj);
51  }
52  return (m_obstacles.size() == m_max_obstacles);
53  }
54 }
55 
57  const CollisionObject *obst) {
58  // todo: subject obstacles to a map, check which is a subject and add the
59  // parent todo: routine to test pair for belonging to a group which was
60  // already added todo: different options of what to return: with ShapeGroups
61  // or raw objects - as a setting
62 
63  // don't add the obstacle if already added
64  auto already_added = m_added_map.find(obst);
65  if (already_added == m_added_map.end()) {
66  m_added_map.emplace(obst, true);
67  auto it = m_parent_map.find(obst);
68 
69  if (it != m_parent_map.end()) {
70  if (m_ungroup_sg && m_ungroup_tvobst) {
71  if (addRequestResultObstacleObject(obst->shared_from_this()))
72  return true;
73  } else {
74  bool found_sg = false;
75  bool found_tvobst = false;
76 
77  // find all entries corresponding to the obstacle (obstacle itself and
78  // its parents in the CC)
79 
80  for (auto &member_obstacle : it->second) {
81  const CollisionObject *memb_obst = member_obstacle.get();
82  auto already_added_parent = m_added_map_parent.find(memb_obst);
83  if (already_added_parent == m_added_map_parent.end()) {
84  m_added_map_parent.emplace(memb_obst, true);
85 
86  FCL_COLLISION_ENTITY_TYPE memb_obst_entity_type =
87  get_object_fcl_entity_type(memb_obst);
88 
89  switch (memb_obst_entity_type) {
91  if (!m_ungroup_tvobst) // if registered tv obstacle parents
92  // should be added as a group
93  {
94  if (addRequestResultObstacleObject(member_obstacle))
95  return true;
96  } else // or as an individual object
97  {
98  found_tvobst = true;
99  }
100  break;
102  if (!m_ungroup_sg) {
103  if (addRequestResultObstacleObject(member_obstacle))
104  return true;
105  } else {
106  found_sg = true;
107  }
108  break;
109  default:
110  if (addRequestResultObstacleObject(member_obstacle))
111  return true;
112  }
113  }
114  }
115  if (found_sg || found_tvobst) {
116  if (addRequestResultObstacleObject(obst->shared_from_this()))
117  return true;
118  }
119  }
120 
121  } else {
122  // std::cout << "parent obj not found";
123 #if ENABLE_COLLISION_TESTS
124 // collision::test::log_parentmap_failure(obst->shared_from_this());
125 #endif
126  }
127  }
128  return false;
129 }
130 
132  const CollisionObject *obst) {
133  auto already_added = m_added_map.find(obst);
134  if (already_added == m_added_map.end()) {
135  m_added_map.emplace(obst, true);
136  // auto it = m_parent_map.find(obst);
137  m_result.push_back(obst);
138  // m_cc->addCollisionObject(obst->shared_from_this());
139  // if( it != m_parent_map.end() )
140  //{
141 
142  // for(auto &member_obstacle: it->second)
143  // {
144  // m_cc->addCollisionObject(member_obstacle);
145  // }
146  //}
147  }
148 }
149 
150 } // namespace solverFCL
151 } // namespace solvers
152 } // namespace collision
void addRequestResultList(std::list< int > list1, std::list< int > list2)
std::shared_ptr< const CollisionObject > CollisionObjectConstPtr
bool testPair(std::pair< fcl::CollisionObject< FCL_PRECISION > *, fcl::CollisionObject< FCL_PRECISION > *> pair)
FCL_COLLISION_ENTITY_TYPE get_object_fcl_entity_type(const CollisionObject *obj2)
Definition: fcl_helpers.h:11
std::set< std::pair< fcl::CollisionObject< FCL_PRECISION > *, fcl::CollisionObject< FCL_PRECISION > * > > checkedPairs
Base class for CollisionObjects and some of their groups.
std::set< std::pair< int, int > > getRequestResultPairs() const