src/broadphase/broadphase_dynamic_AABB_tree.cpp
Go to the documentation of this file.
1 /*
2  * Software License Agreement (BSD License)
3  *
4  * Copyright (c) 2011-2014, Willow Garage, Inc.
5  * Copyright (c) 2014-2016, Open Source Robotics Foundation
6  * All rights reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions
10  * are met:
11  *
12  * * Redistributions of source code must retain the above copyright
13  * notice, this list of conditions and the following disclaimer.
14  * * Redistributions in binary form must reproduce the above
15  * copyright notice, this list of conditions and the following
16  * disclaimer in the documentation and/or other materials provided
17  * with the distribution.
18  * * Neither the name of Open Source Robotics Foundation nor the names of its
19  * contributors may be used to endorse or promote products derived
20  * from this software without specific prior written permission.
21  *
22  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
25  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
26  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
27  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
28  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
29  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
30  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
32  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33  * POSSIBILITY OF SUCH DAMAGE.
34  */
35 
39 
40 #ifdef COAL_HAVE_OCTOMAP
41 #include "coal/octree.h"
42 #endif
43 
44 #include "coal/BV/BV.h"
46 
47 #include <limits>
48 
49 namespace coal {
50 namespace detail {
51 
52 namespace dynamic_AABB_tree {
53 
54 #if COAL_HAVE_OCTOMAP
55 //==============================================================================
56 bool collisionRecurse_(DynamicAABBTreeCollisionManager::DynamicAABBNode* root1,
57  const OcTree* tree2, const OcTree::OcTreeNode* root2,
58  const AABB& root2_bv, const Transform3s& tf2,
59  CollisionCallBackBase* callback) {
60  if (!root2) {
61  if (root1->isLeaf()) {
62  CollisionObject* obj1 = static_cast<CollisionObject*>(root1->data);
63 
64  if (!obj1->collisionGeometry()->isFree()) {
65  OBB obb1, obb2;
66  convertBV(root1->bv, Transform3s::Identity(), obb1);
67  convertBV(root2_bv, tf2, obb2);
68 
69  if (obb1.overlap(obb2)) {
70  Box* box = new Box();
71  Transform3s box_tf;
72  constructBox(root2_bv, tf2, *box, box_tf);
73 
74  box->cost_density = tree2->getDefaultOccupancy();
75 
76  CollisionObject obj2(shared_ptr<CollisionGeometry>(box), box_tf);
77  return (*callback)(obj1, &obj2);
78  }
79  }
80  } else {
81  if (collisionRecurse_(root1->children[0], tree2, nullptr, root2_bv, tf2,
82  callback))
83  return true;
84  if (collisionRecurse_(root1->children[1], tree2, nullptr, root2_bv, tf2,
85  callback))
86  return true;
87  }
88 
89  return false;
90  } else if (root1->isLeaf() && !tree2->nodeHasChildren(root2)) {
91  CollisionObject* obj1 = static_cast<CollisionObject*>(root1->data);
92 
93  if (!tree2->isNodeFree(root2) && !obj1->collisionGeometry()->isFree()) {
94  OBB obb1, obb2;
95  convertBV(root1->bv, Transform3s::Identity(), obb1);
96  convertBV(root2_bv, tf2, obb2);
97 
98  if (obb1.overlap(obb2)) {
99  Box* box = new Box();
100  Transform3s box_tf;
101  constructBox(root2_bv, tf2, *box, box_tf);
102 
103  box->cost_density = root2->getOccupancy();
104  box->threshold_occupied = tree2->getOccupancyThres();
105 
106  CollisionObject obj2(shared_ptr<CollisionGeometry>(box), box_tf);
107  return (*callback)(obj1, &obj2);
108  } else
109  return false;
110  } else
111  return false;
112  }
113 
114  OBB obb1, obb2;
115  convertBV(root1->bv, Transform3s::Identity(), obb1);
116  convertBV(root2_bv, tf2, obb2);
117 
118  if (tree2->isNodeFree(root2) || !obb1.overlap(obb2)) return false;
119 
120  if (!tree2->nodeHasChildren(root2) ||
121  (!root1->isLeaf() && (root1->bv.size() > root2_bv.size()))) {
122  if (collisionRecurse_(root1->children[0], tree2, root2, root2_bv, tf2,
123  callback))
124  return true;
125  if (collisionRecurse_(root1->children[1], tree2, root2, root2_bv, tf2,
126  callback))
127  return true;
128  } else {
129  for (unsigned int i = 0; i < 8; ++i) {
130  if (tree2->nodeChildExists(root2, i)) {
131  const OcTree::OcTreeNode* child = tree2->getNodeChild(root2, i);
132  AABB child_bv;
133  computeChildBV(root2_bv, i, child_bv);
134 
135  if (collisionRecurse_(root1, tree2, child, child_bv, tf2, callback))
136  return true;
137  } else {
138  AABB child_bv;
139  computeChildBV(root2_bv, i, child_bv);
140  if (collisionRecurse_(root1, tree2, nullptr, child_bv, tf2, callback))
141  return true;
142  }
143  }
144  }
145  return false;
146 }
147 
148 //==============================================================================
149 bool distanceRecurse_(DynamicAABBTreeCollisionManager::DynamicAABBNode* root1,
150  const OcTree* tree2, const OcTree::OcTreeNode* root2,
151  const AABB& root2_bv, const Transform3s& tf2,
152  DistanceCallBackBase* callback, CoalScalar& min_dist) {
153  if (root1->isLeaf() && !tree2->nodeHasChildren(root2)) {
154  if (tree2->isNodeOccupied(root2)) {
155  Box* box = new Box();
156  Transform3s box_tf;
157  constructBox(root2_bv, tf2, *box, box_tf);
158  CollisionObject obj(shared_ptr<CollisionGeometry>(box), box_tf);
159  return (*callback)(static_cast<CollisionObject*>(root1->data), &obj,
160  min_dist);
161  } else
162  return false;
163  }
164 
165  if (!tree2->isNodeOccupied(root2)) return false;
166 
167  if (!tree2->nodeHasChildren(root2) ||
168  (!root1->isLeaf() && (root1->bv.size() > root2_bv.size()))) {
169  AABB aabb2;
170  convertBV(root2_bv, tf2, aabb2);
171 
172  CoalScalar d1 = aabb2.distance(root1->children[0]->bv);
173  CoalScalar d2 = aabb2.distance(root1->children[1]->bv);
174 
175  if (d2 < d1) {
176  if (d2 < min_dist) {
177  if (distanceRecurse_(root1->children[1], tree2, root2, root2_bv, tf2,
178  callback, min_dist))
179  return true;
180  }
181 
182  if (d1 < min_dist) {
183  if (distanceRecurse_(root1->children[0], tree2, root2, root2_bv, tf2,
184  callback, min_dist))
185  return true;
186  }
187  } else {
188  if (d1 < min_dist) {
189  if (distanceRecurse_(root1->children[0], tree2, root2, root2_bv, tf2,
190  callback, min_dist))
191  return true;
192  }
193 
194  if (d2 < min_dist) {
195  if (distanceRecurse_(root1->children[1], tree2, root2, root2_bv, tf2,
196  callback, min_dist))
197  return true;
198  }
199  }
200  } else {
201  for (unsigned int i = 0; i < 8; ++i) {
202  if (tree2->nodeChildExists(root2, i)) {
203  const OcTree::OcTreeNode* child = tree2->getNodeChild(root2, i);
204  AABB child_bv;
205  computeChildBV(root2_bv, i, child_bv);
206 
207  AABB aabb2;
208  convertBV(child_bv, tf2, aabb2);
209  CoalScalar d = root1->bv.distance(aabb2);
210 
211  if (d < min_dist) {
212  if (distanceRecurse_(root1, tree2, child, child_bv, tf2, callback,
213  min_dist))
214  return true;
215  }
216  }
217  }
218  }
219 
220  return false;
221 }
222 
223 //==============================================================================
225  const OcTree* tree2, const OcTree::OcTreeNode* root2,
226  const AABB& root2_bv, const Transform3s& tf2,
227  CollisionCallBackBase* callback) {
228  if (tf2.rotation().isIdentity())
229  return collisionRecurse_(root1, tree2, root2, root2_bv, tf2.translation(),
230  callback);
231  else // has rotation
232  return collisionRecurse_(root1, tree2, root2, root2_bv, tf2, callback);
233 }
234 
235 //==============================================================================
237  const OcTree* tree2, const OcTree::OcTreeNode* root2,
238  const AABB& root2_bv, const Transform3s& tf2,
239  DistanceCallBackBase* callback, CoalScalar& min_dist) {
240  if (tf2.rotation().isIdentity())
241  return distanceRecurse_(root1, tree2, root2, root2_bv, tf2.translation(),
242  callback, min_dist);
243  else
244  return distanceRecurse_(root1, tree2, root2, root2_bv, tf2, callback,
245  min_dist);
246 }
247 
248 #endif
249 
250 //==============================================================================
253  if ((o1->getNodeType() == GEOM_HALFSPACE ||
254  o1->getNodeType() == GEOM_PLANE) &&
255  (o2->getNodeType() == GEOM_HALFSPACE ||
256  o2->getNodeType() == GEOM_PLANE)) {
257  // Halfspace-plane / Halfspace-plane collision, there is no need to check
258  // AABBs. We can directly use the callback.
259  return (*callback)(o1, o2);
260  }
261 
262  bool overlap = false;
263  if (o1->getNodeType() == GEOM_HALFSPACE || o1->getNodeType() == GEOM_PLANE) {
264  if (o1->getNodeType() == GEOM_HALFSPACE) {
265  const auto& halfspace =
266  static_cast<const Halfspace&>(*(o1->collisionGeometryPtr()));
267  overlap = o2->getAABB().overlap(transform(halfspace, o1->getTransform()));
268  } else {
269  const auto& plane =
270  static_cast<const Plane&>(*(o1->collisionGeometryPtr()));
271  overlap = o2->getAABB().overlap(transform(plane, o1->getTransform()));
272  }
273  } //
274  else if (o2->getNodeType() == GEOM_HALFSPACE ||
275  o2->getNodeType() == GEOM_PLANE) {
276  if (o2->getNodeType() == GEOM_HALFSPACE) {
277  const auto& halfspace =
278  static_cast<const Halfspace&>(*(o2->collisionGeometryPtr()));
279  overlap = o1->getAABB().overlap(transform(halfspace, o2->getTransform()));
280  } else {
281  const auto& plane =
282  static_cast<const Plane&>(*(o2->collisionGeometryPtr()));
283  overlap = o1->getAABB().overlap(transform(plane, o2->getTransform()));
284  }
285  } //
286  else {
287  overlap = o1->getAABB().overlap(o2->getAABB());
288  }
289 
290  if (overlap) {
291  return (*callback)(o1, o2);
292  }
293  return false;
294 }
295 
296 //==============================================================================
299  // This function assumes that at least node1 or node2 is not a leaf of the
300  // tree.
301  if (node1->isLeaf()) {
302  CollisionObject* o1 = static_cast<CollisionObject*>(node1->data);
303  if (o1->getNodeType() == GEOM_HALFSPACE ||
304  o1->getNodeType() == GEOM_PLANE) {
305  if (o1->getNodeType() == GEOM_HALFSPACE) {
306  const auto& halfspace =
307  static_cast<const Halfspace&>(*(o1->collisionGeometryPtr()));
308  return node2->bv.overlap(transform(halfspace, o1->getTransform()));
309  }
310  const auto& plane =
311  static_cast<const Plane&>(*(o1->collisionGeometryPtr()));
312  return node2->bv.overlap(transform(plane, o1->getTransform()));
313  }
314  }
315 
316  if (node2->isLeaf()) {
317  CollisionObject* o2 = static_cast<CollisionObject*>(node2->data);
318  if (o2->getNodeType() == GEOM_HALFSPACE ||
319  o2->getNodeType() == GEOM_PLANE) {
320  if (o2->getNodeType() == GEOM_HALFSPACE) {
321  const auto& halfspace =
322  static_cast<const Halfspace&>(*(o2->collisionGeometryPtr()));
323  return node1->bv.overlap(transform(halfspace, o2->getTransform()));
324  }
325  const auto& plane =
326  static_cast<const Plane&>(*(o2->collisionGeometryPtr()));
327  return node1->bv.overlap(transform(plane, o2->getTransform()));
328  }
329  }
330 
331  return node1->bv.overlap(node2->bv);
332 }
333 
334 //==============================================================================
338  if (root1->isLeaf() && root2->isLeaf()) {
339  CollisionObject* o1 = static_cast<CollisionObject*>(root1->data);
340  CollisionObject* o2 = static_cast<CollisionObject*>(root2->data);
341  return leafCollide(o1, o2, callback);
342  }
343 
344  if (!nodeCollide(root1, root2)) {
345  return false;
346  }
347 
348  if (root2->isLeaf() ||
349  (!root1->isLeaf() && (root1->bv.size() > root2->bv.size()))) {
350  if (collisionRecurse(root1->children[0], root2, callback)) return true;
351  if (collisionRecurse(root1->children[1], root2, callback)) return true;
352  } else {
353  if (collisionRecurse(root1, root2->children[0], callback)) return true;
354  if (collisionRecurse(root1, root2->children[1], callback)) return true;
355  }
356  return false;
357 }
358 
359 //==============================================================================
362  if (root->isLeaf()) {
363  CollisionObject* leaf = static_cast<CollisionObject*>(root->data);
364  return leafCollide(leaf, query, callback);
365  }
366 
367  // Create a temporary node, attached to no tree.
368  // This allows to reuse the `nodeCollide` function, which only checks for
369  // overlap between the AABBs of two nodes.
371  query_node.data = query;
372  query_node.bv = query->getAABB();
373  query_node.parent = nullptr;
374  query_node.children[1] = nullptr;
375  if (!nodeCollide(root, &query_node)) {
376  return false;
377  }
378 
379  size_t select_res =
380  select(query->getAABB(), *(root->children[0]), *(root->children[1]));
381 
382  if (collisionRecurse(root->children[select_res], query, callback))
383  return true;
384 
385  if (collisionRecurse(root->children[1 - select_res], query, callback))
386  return true;
387 
388  return false;
389 }
390 
391 //==============================================================================
395  if (root->isLeaf()) return false;
396 
397  if (selfCollisionRecurse(root->children[0], callback)) return true;
398 
399  if (selfCollisionRecurse(root->children[1], callback)) return true;
400 
401  if (collisionRecurse(root->children[0], root->children[1], callback))
402  return true;
403 
404  return false;
405 }
406 
407 //==============================================================================
411  if (root1->isLeaf() && root2->isLeaf()) {
412  CollisionObject* root1_obj = static_cast<CollisionObject*>(root1->data);
413  CollisionObject* root2_obj = static_cast<CollisionObject*>(root2->data);
414  return (*callback)(root1_obj, root2_obj, min_dist);
415  }
416 
417  if (root2->isLeaf() ||
418  (!root1->isLeaf() && (root1->bv.size() > root2->bv.size()))) {
419  CoalScalar d1 = root2->bv.distance(root1->children[0]->bv);
420  CoalScalar d2 = root2->bv.distance(root1->children[1]->bv);
421 
422  if (d2 < d1) {
423  if (d2 < min_dist) {
424  if (distanceRecurse(root1->children[1], root2, callback, min_dist))
425  return true;
426  }
427 
428  if (d1 < min_dist) {
429  if (distanceRecurse(root1->children[0], root2, callback, min_dist))
430  return true;
431  }
432  } else {
433  if (d1 < min_dist) {
434  if (distanceRecurse(root1->children[0], root2, callback, min_dist))
435  return true;
436  }
437 
438  if (d2 < min_dist) {
439  if (distanceRecurse(root1->children[1], root2, callback, min_dist))
440  return true;
441  }
442  }
443  } else {
444  CoalScalar d1 = root1->bv.distance(root2->children[0]->bv);
445  CoalScalar d2 = root1->bv.distance(root2->children[1]->bv);
446 
447  if (d2 < d1) {
448  if (d2 < min_dist) {
449  if (distanceRecurse(root1, root2->children[1], callback, min_dist))
450  return true;
451  }
452 
453  if (d1 < min_dist) {
454  if (distanceRecurse(root1, root2->children[0], callback, min_dist))
455  return true;
456  }
457  } else {
458  if (d1 < min_dist) {
459  if (distanceRecurse(root1, root2->children[0], callback, min_dist))
460  return true;
461  }
462 
463  if (d2 < min_dist) {
464  if (distanceRecurse(root1, root2->children[1], callback, min_dist))
465  return true;
466  }
467  }
468  }
469 
470  return false;
471 }
472 
473 //==============================================================================
476  CoalScalar& min_dist) {
477  if (root->isLeaf()) {
478  CollisionObject* root_obj = static_cast<CollisionObject*>(root->data);
479  return (*callback)(root_obj, query, min_dist);
480  }
481 
482  CoalScalar d1 = query->getAABB().distance(root->children[0]->bv);
483  CoalScalar d2 = query->getAABB().distance(root->children[1]->bv);
484 
485  if (d2 < d1) {
486  if (d2 < min_dist) {
487  if (distanceRecurse(root->children[1], query, callback, min_dist))
488  return true;
489  }
490 
491  if (d1 < min_dist) {
492  if (distanceRecurse(root->children[0], query, callback, min_dist))
493  return true;
494  }
495  } else {
496  if (d1 < min_dist) {
497  if (distanceRecurse(root->children[0], query, callback, min_dist))
498  return true;
499  }
500 
501  if (d2 < min_dist) {
502  if (distanceRecurse(root->children[1], query, callback, min_dist))
503  return true;
504  }
505  }
506 
507  return false;
508 }
509 
510 //==============================================================================
513  if (root->isLeaf()) return false;
514 
515  if (selfDistanceRecurse(root->children[0], callback, min_dist)) return true;
516 
517  if (selfDistanceRecurse(root->children[1], callback, min_dist)) return true;
518 
519  if (distanceRecurse(root->children[0], root->children[1], callback, min_dist))
520  return true;
521 
522  return false;
523 }
524 
525 } // namespace dynamic_AABB_tree
526 
527 } // namespace detail
528 
529 //==============================================================================
531  tree_topdown_balance_threshold = &dtree.bu_threshold;
532  tree_topdown_level = &dtree.topdown_level;
536  *tree_topdown_level = 0;
537  tree_init_level = 0;
538  setup_ = false;
539 
540  // from experiment, this is the optimal setting
543 }
544 
545 //==============================================================================
547  const std::vector<CollisionObject*>& other_objs) {
548  if (other_objs.empty()) return;
549 
550  if (size() > 0) {
552  } else {
553  std::vector<DynamicAABBNode*> leaves(other_objs.size());
554  table.rehash(other_objs.size());
555  for (size_t i = 0, size = other_objs.size(); i < size; ++i) {
556  DynamicAABBNode* node =
557  new DynamicAABBNode; // node will be managed by the dtree
558  node->bv = other_objs[i]->getAABB();
559  node->parent = nullptr;
560  node->children[1] = nullptr;
561  node->data = other_objs[i];
562  table[other_objs[i]] = node;
563  leaves[i] = node;
564  }
565 
566  dtree.init(leaves, tree_init_level);
567 
568  setup_ = true;
569  }
570 }
571 
572 //==============================================================================
574  DynamicAABBNode* node = dtree.insert(obj->getAABB(), obj);
575  table[obj] = node;
576 }
577 
578 //==============================================================================
580  DynamicAABBNode* node = table[obj];
581  table.erase(obj);
582  dtree.remove(node);
583 }
584 
585 //==============================================================================
587  if (!setup_) {
588  size_t num = dtree.size();
589  if (num == 0) {
590  setup_ = true;
591  return;
592  }
593 
594  size_t height = dtree.getMaxHeight();
595 
596  if (((CoalScalar)height - std::log((CoalScalar)num) / std::log(2.0)) <
598  dtree.balanceIncremental(tree_incremental_balance_pass);
599  else
600  dtree.balanceTopdown();
601 
602  setup_ = true;
603  }
604 }
605 
606 //==============================================================================
608  for (auto it = table.cbegin(); it != table.cend(); ++it) {
609  CollisionObject* obj = it->first;
610  DynamicAABBNode* node = it->second;
611  node->bv = obj->getAABB();
612  if (node->bv.volume() <= 0.)
613  COAL_THROW_PRETTY("The bounding volume has a negative volume.",
614  std::invalid_argument)
615  }
616 
617  dtree.refit();
618  setup_ = false;
619 
620  setup();
621 }
622 
623 //==============================================================================
625  const auto it = table.find(updated_obj);
626  if (it != table.end()) {
627  DynamicAABBNode* node = it->second;
628  if (!(node->bv == updated_obj->getAABB()))
629  dtree.update(node, updated_obj->getAABB());
630  }
631  setup_ = false;
632 }
633 
634 //==============================================================================
636  update_(updated_obj);
637  setup();
638 }
639 
640 //==============================================================================
642  const std::vector<CollisionObject*>& updated_objs) {
643  for (size_t i = 0, size = updated_objs.size(); i < size; ++i)
644  update_(updated_objs[i]);
645  setup();
646 }
647 
648 //==============================================================================
650  dtree.clear();
651  table.clear();
652 }
653 
654 //==============================================================================
656  std::vector<CollisionObject*>& objs) const {
657  objs.resize(this->size());
659  table.begin(), table.end(), objs.begin(),
660  std::bind(&DynamicAABBTable::value_type::first, std::placeholders::_1));
661 }
662 
663 //==============================================================================
666  callback->init();
667  if (size() == 0) return;
668  switch (obj->collisionGeometry()->getNodeType()) {
669 #if COAL_HAVE_OCTOMAP
670  case GEOM_OCTREE: {
672  const OcTree* octree =
673  static_cast<const OcTree*>(obj->collisionGeometryPtr());
675  dtree.getRoot(), octree, octree->getRoot(), octree->getRootBV(),
676  obj->getTransform(), callback);
677  } else
679  callback);
680  } break;
681 #endif
682  default:
684  callback);
685  }
686 }
687 
688 //==============================================================================
691  callback->init();
692  if (size() == 0) return;
693  CoalScalar min_dist = (std::numeric_limits<CoalScalar>::max)();
694  switch (obj->collisionGeometry()->getNodeType()) {
695 #if COAL_HAVE_OCTOMAP
696  case GEOM_OCTREE: {
698  const OcTree* octree =
699  static_cast<const OcTree*>(obj->collisionGeometryPtr());
701  dtree.getRoot(), octree, octree->getRoot(), octree->getRootBV(),
702  obj->getTransform(), callback, min_dist);
703  } else
705  callback, min_dist);
706  } break;
707 #endif
708  default:
710  min_dist);
711  }
712 }
713 
714 //==============================================================================
717  callback->init();
718  if (size() == 0) return;
720 }
721 
722 //==============================================================================
725  callback->init();
726  if (size() == 0) return;
727  CoalScalar min_dist = (std::numeric_limits<CoalScalar>::max)();
729  min_dist);
730 }
731 
732 //==============================================================================
734  BroadPhaseCollisionManager* other_manager_,
736  callback->init();
737  DynamicAABBTreeCollisionManager* other_manager =
738  static_cast<DynamicAABBTreeCollisionManager*>(other_manager_);
739  if ((size() == 0) || (other_manager->size() == 0)) return;
741  dtree.getRoot(), other_manager->dtree.getRoot(), callback);
742 }
743 
744 //==============================================================================
746  BroadPhaseCollisionManager* other_manager_,
748  callback->init();
749  DynamicAABBTreeCollisionManager* other_manager =
750  static_cast<DynamicAABBTreeCollisionManager*>(other_manager_);
751  if ((size() == 0) || (other_manager->size() == 0)) return;
752  CoalScalar min_dist = (std::numeric_limits<CoalScalar>::max)();
754  dtree.getRoot(), other_manager->dtree.getRoot(), callback, min_dist);
755 }
756 
757 //==============================================================================
758 bool DynamicAABBTreeCollisionManager::empty() const { return dtree.empty(); }
759 
760 //==============================================================================
761 size_t DynamicAABBTreeCollisionManager::size() const { return dtree.size(); }
762 
763 //==============================================================================
765  const {
766  return dtree;
767 }
768 
770  return dtree;
771 }
772 
773 } // namespace coal
octree.h
geometric_shapes.d1
float d1
Definition: scripts/geometric_shapes.py:31
coal::DynamicAABBTreeCollisionManager::DynamicAABBNode
detail::NodeBase< AABB > DynamicAABBNode
Definition: coal/broadphase/broadphase_dynamic_AABB_tree.h:59
broadphase_dynamic_AABB_tree.h
collision_manager.callback
callback
Definition: collision_manager.py:27
collision_manager.box
box
Definition: collision_manager.py:11
coal::DynamicAABBTreeCollisionManager::tree_init_level
int tree_init_level
Definition: coal/broadphase/broadphase_dynamic_AABB_tree.h:67
coal::DynamicAABBTreeCollisionManager::setup
void setup()
initialize the manager, related with the specific type of manager
Definition: src/broadphase/broadphase_dynamic_AABB_tree.cpp:586
coal::DynamicAABBTreeCollisionManager::unregisterObject
void unregisterObject(CollisionObject *obj)
remove one object from the manager
Definition: src/broadphase/broadphase_dynamic_AABB_tree.cpp:579
coal::DynamicAABBTreeCollisionManager::clear
void clear()
clear the manager
Definition: src/broadphase/broadphase_dynamic_AABB_tree.cpp:649
coal::DynamicAABBTreeCollisionManager
Definition: coal/broadphase/broadphase_dynamic_AABB_tree.h:53
coal::AABB::distance
CoalScalar distance(const AABB &other) const
Distance between two AABBs.
Definition: AABB.cpp:114
coal::CollisionObject::collisionGeometryPtr
const CollisionGeometry * collisionGeometryPtr() const
get raw pointer to collision geometry of the object instance
Definition: coal/collision_object.h:319
coal::CollisionObject::getTransform
const Transform3s & getTransform() const
get object's transform
Definition: coal/collision_object.h:290
coal::Halfspace
Half Space: this is equivalent to the Plane in ODE. A Half space has a priviledged direction: the dir...
Definition: coal/shape/geometric_shapes.h:892
coal::BroadPhaseCollisionManager
Base class for broad phase collision. It helps to accelerate the collision/distance between N objects...
Definition: coal/broadphase/broadphase_collision_manager.h:53
coal::detail::dynamic_AABB_tree::selfDistanceRecurse
bool selfDistanceRecurse(DynamicAABBTreeCollisionManager::DynamicAABBNode *root, DistanceCallBackBase *callback, CoalScalar &min_dist)
Definition: src/broadphase/broadphase_dynamic_AABB_tree.cpp:511
coal::detail::dynamic_AABB_tree::selfCollisionRecurse
bool selfCollisionRecurse(DynamicAABBTreeCollisionManager::DynamicAABBNode *root, CollisionCallBackBase *callback)
Definition: src/broadphase/broadphase_dynamic_AABB_tree.cpp:392
coal
Main namespace.
Definition: coal/broadphase/broadphase_bruteforce.h:44
coal::BroadPhaseCollisionManager::getObjects
virtual std::vector< CollisionObject * > getObjects() const
return the objects managed by the manager
Definition: coal/broadphase/broadphase_collision_manager.h:87
coal::DynamicAABBTreeCollisionManager::tree_incremental_balance_pass
int tree_incremental_balance_pass
Definition: coal/broadphase/broadphase_dynamic_AABB_tree.h:64
coal::detail::dynamic_AABB_tree::collisionRecurse
bool collisionRecurse(DynamicAABBTreeCollisionManager::DynamicAABBNode *root1, DynamicAABBTreeCollisionManager::DynamicAABBNode *root2, CollisionCallBackBase *callback)
Definition: src/broadphase/broadphase_dynamic_AABB_tree.cpp:335
coal::DynamicAABBTreeCollisionManager::distance
void distance(CollisionObject *obj, DistanceCallBackBase *callback) const
perform distance computation between one object and all the objects belonging to the manager
Definition: src/broadphase/broadphase_dynamic_AABB_tree.cpp:689
coal::detail::dynamic_AABB_tree::leafCollide
bool leafCollide(CollisionObject *o1, CollisionObject *o2, CollisionCallBackBase *callback)
Definition: src/broadphase/broadphase_dynamic_AABB_tree.cpp:251
coal::detail::dynamic_AABB_tree::distanceRecurse
bool distanceRecurse(DynamicAABBTreeCollisionManager::DynamicAABBNode *root1, DynamicAABBTreeCollisionManager::DynamicAABBNode *root2, DistanceCallBackBase *callback, CoalScalar &min_dist)
Definition: src/broadphase/broadphase_dynamic_AABB_tree.cpp:408
coal::detail::NodeBase::data
void * data
Definition: coal/broadphase/detail/node_base.h:65
octree
Definition: octree.py:1
coal::BroadPhaseCollisionManager::registerObjects
virtual void registerObjects(const std::vector< CollisionObject * > &other_objs)
add objects to the manager
Definition: broadphase_collision_manager.cpp:54
coal::DynamicAABBTreeCollisionManager::getTree
const detail::HierarchyTree< AABB > & getTree() const
returns the AABB tree structure.
Definition: src/broadphase/broadphase_dynamic_AABB_tree.cpp:764
BV.h
coal::DynamicAABBTreeCollisionManager::DynamicAABBTreeCollisionManager
DynamicAABBTreeCollisionManager()
Definition: src/broadphase/broadphase_dynamic_AABB_tree.cpp:530
coal::Plane
Infinite plane. A plane can be viewed as two half spaces; it has no priviledged direction....
Definition: coal/shape/geometric_shapes.h:983
coal::constructBox
COAL_DLLAPI void constructBox(const AABB &bv, Box &box, Transform3s &tf)
construct a box shape (with a configuration) from a given bounding volume
Definition: geometric_shapes_utility.cpp:1011
coal::DynamicAABBTreeCollisionManager::registerObjects
void registerObjects(const std::vector< CollisionObject * > &other_objs)
add objects to the manager
Definition: src/broadphase/broadphase_dynamic_AABB_tree.cpp:546
coal::DynamicAABBTreeCollisionManager::tree_topdown_level
int * tree_topdown_level
Definition: coal/broadphase/broadphase_dynamic_AABB_tree.h:66
coal::AABB::overlap
bool overlap(const AABB &other) const
Check whether two AABB are overlap.
Definition: coal/BV/AABB.h:111
coal::GEOM_PLANE
@ GEOM_PLANE
Definition: coal/collision_object.h:80
coal::detail::select
size_t select(const NodeBase< BV > &query, const NodeBase< BV > &node1, const NodeBase< BV > &node2)
select from node1 and node2 which is close to a given query. 0 for node1 and 1 for node2
Definition: coal/broadphase/detail/hierarchy_tree-inl.h:952
coal::detail::dynamic_AABB_tree::nodeCollide
bool nodeCollide(DynamicAABBTreeCollisionManager::DynamicAABBNode *node1, DynamicAABBTreeCollisionManager::DynamicAABBNode *node2)
Definition: src/broadphase/broadphase_dynamic_AABB_tree.cpp:297
d
d
coal::DynamicAABBTreeCollisionManager::setup_
bool setup_
Definition: coal/broadphase/broadphase_dynamic_AABB_tree.h:141
coal::DynamicAABBTreeCollisionManager::table
std::unordered_map< CollisionObject *, DynamicAABBNode * > table
Definition: coal/broadphase/broadphase_dynamic_AABB_tree.h:139
coal::detail::NodeBase::children
NodeBase< BV > * children[2]
for leaf node, children nodes
Definition: coal/broadphase/detail/node_base.h:64
coal::detail::HierarchyTree
Class for hierarchy tree structure.
Definition: coal/broadphase/detail/hierarchy_tree.h:56
coal::GEOM_HALFSPACE
@ GEOM_HALFSPACE
Definition: coal/collision_object.h:81
coal::transform
COAL_DLLAPI Halfspace transform(const Halfspace &a, const Transform3s &tf)
Definition: geometric_shapes_utility.cpp:248
COAL_THROW_PRETTY
#define COAL_THROW_PRETTY(message, exception)
Definition: include/coal/fwd.hh:64
coal::computeChildBV
static void computeChildBV(const AABB &root_bv, unsigned int i, AABB &child_bv)
compute the bounding volume of an octree node's i-th child
Definition: coal/octree.h:299
coal::Transform3s::Identity
static Transform3s Identity()
Definition: coal/math/transform.h:68
coal::DynamicAABBTreeCollisionManager::octree_as_geometry_collide
bool octree_as_geometry_collide
Definition: coal/broadphase/broadphase_dynamic_AABB_tree.h:69
coal::detail::overlap
bool overlap(CoalScalar a1, CoalScalar a2, CoalScalar b1, CoalScalar b2)
returns 1 if the intervals overlap, and 0 otherwise
Definition: interval_tree.cpp:412
coal::DistanceCallBackBase
Base callback class for distance queries. This class can be supersed by child classes to provide desi...
Definition: coal/broadphase/broadphase_callbacks.h:72
coal::DynamicAABBTreeCollisionManager::empty
bool empty() const
whether the manager is empty
Definition: src/broadphase/broadphase_dynamic_AABB_tree.cpp:758
coal::CollisionObject
the object for collision or distance computation, contains the geometry and the transform information
Definition: coal/collision_object.h:214
coal::DynamicAABBTreeCollisionManager::collide
void collide(CollisionObject *obj, CollisionCallBackBase *callback) const
perform collision test between one object and all the objects belonging to the manager
Definition: src/broadphase/broadphase_dynamic_AABB_tree.cpp:664
coal::detail::NodeBase::parent
NodeBase< BV > * parent
pointer to parent node
Definition: coal/broadphase/detail/node_base.h:54
gjk.tf2
tuple tf2
Definition: test/scripts/gjk.py:36
coal::CollisionObject::getAABB
const AABB & getAABB() const
get the AABB in world space
Definition: coal/collision_object.h:252
coal::DynamicAABBTreeCollisionManager::octree_as_geometry_distance
bool octree_as_geometry_distance
Definition: coal/broadphase/broadphase_dynamic_AABB_tree.h:70
coal::DynamicAABBTreeCollisionManager::tree_topdown_balance_threshold
int * tree_topdown_balance_threshold
Definition: coal/broadphase/broadphase_dynamic_AABB_tree.h:65
coal::GEOM_OCTREE
@ GEOM_OCTREE
Definition: coal/collision_object.h:83
coal::detail::NodeBase::isLeaf
bool isLeaf() const
whether is a leaf
Definition: coal/broadphase/detail/node_base-inl.h:54
coal::OcTree::OcTreeNode
octomap::OcTreeNode OcTreeNode
Definition: coal/octree.h:63
coal::OcTree
Octree is one type of collision geometry which can encode uncertainty information in the sensor data.
Definition: coal/octree.h:53
coal::DynamicAABBTreeCollisionManager::update_
void update_(CollisionObject *updated_obj)
Definition: src/broadphase/broadphase_dynamic_AABB_tree.cpp:624
coal::CollisionObject::getNodeType
NODE_TYPE getNodeType() const
get the node type
Definition: coal/collision_object.h:249
geometric_shapes_utility.h
coal::convertBV
static void convertBV(const BV1 &bv1, const Transform3s &tf1, BV2 &bv2)
Convert a bounding volume of type BV1 in configuration tf1 to bounding volume of type BV2 in identity...
Definition: coal/BV/BV.h:276
coal::DynamicAABBTreeCollisionManager::update
virtual void update()
update the condition of manager
Definition: src/broadphase/broadphase_dynamic_AABB_tree.cpp:607
coal::DynamicAABBTreeCollisionManager::registerObject
void registerObject(CollisionObject *obj)
add one object to the manager
Definition: src/broadphase/broadphase_dynamic_AABB_tree.cpp:573
coal::DynamicAABBTreeCollisionManager::size
size_t size() const
the number of objects managed by the manager
Definition: src/broadphase/broadphase_dynamic_AABB_tree.cpp:761
coal::CollisionCallBackBase
Base callback class for collision queries. This class can be supersed by child classes to provide des...
Definition: coal/broadphase/broadphase_callbacks.h:49
coal::detail::NodeBase::bv
BV bv
the bounding volume for the node
Definition: coal/broadphase/detail/node_base.h:51
coal::DynamicAABBTreeCollisionManager::max_tree_nonbalanced_level
int max_tree_nonbalanced_level
Definition: coal/broadphase/broadphase_dynamic_AABB_tree.h:63
coal::CoalScalar
double CoalScalar
Definition: coal/data_types.h:76
coal::detail::NodeBase
dynamic AABB tree node
Definition: coal/broadphase/detail/node_base.h:49
coal::DynamicAABBTreeCollisionManager::dtree
detail::HierarchyTree< AABB > dtree
Definition: coal/broadphase/broadphase_dynamic_AABB_tree.h:138
coal::CollisionObject::collisionGeometry
const shared_ptr< const CollisionGeometry > collisionGeometry() const
get shared pointer to collision geometry of the object instance
Definition: coal/collision_object.h:311


hpp-fcl
Author(s):
autogenerated on Sat Nov 23 2024 03:44:57