collision_node.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-2015, 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 
38 #include <../src/collision_node.h>
40 
41 namespace coal {
42 
44  CoalScalar sqrDistLowerBound) {
45  COAL_UNUSED_VARIABLE(result);
46  const CoalScalar dummy_precision =
48  COAL_UNUSED_VARIABLE(dummy_precision);
49  if (sqrDistLowerBound == 0) {
50  COAL_ASSERT(result.distance_lower_bound <= dummy_precision,
51  "Distance lower bound should not be positive.",
52  std::logic_error);
53  } else {
55  sqrDistLowerBound <
56  dummy_precision,
57  "Distance lower bound and sqrDistLowerBound should coincide.",
58  std::logic_error);
59  }
60 }
61 
62 void collide(CollisionTraversalNodeBase* node, const CollisionRequest& request,
63  CollisionResult& result, BVHFrontList* front_list,
64  bool recursive) {
65  if (front_list && front_list->size() > 0) {
66  propagateBVHFrontListCollisionRecurse(node, request, result, front_list);
67  } else {
68  CoalScalar sqrDistLowerBound = 0;
69  if (recursive)
70  collisionRecurse(node, 0, 0, front_list, sqrDistLowerBound);
71  else
72  collisionNonRecurse(node, front_list, sqrDistLowerBound);
73  if (!std::isnan(sqrDistLowerBound)) {
74  checkResultLowerBound(result, sqrDistLowerBound);
75  }
76  }
77 }
78 
79 void distance(DistanceTraversalNodeBase* node, BVHFrontList* front_list,
80  unsigned int qsize) {
81  node->preprocess();
82 
83  if (qsize <= 2)
84  distanceRecurse(node, 0, 0, front_list);
85  else
86  distanceQueueRecurse(node, 0, 0, front_list, qsize);
87 
88  node->postprocess();
89 }
90 
91 } // namespace coal
COAL_ASSERT
#define COAL_ASSERT(check, message, exception)
Definition: include/coal/fwd.hh:82
coal::propagateBVHFrontListCollisionRecurse
void propagateBVHFrontListCollisionRecurse(CollisionTraversalNodeBase *node, const CollisionRequest &, CollisionResult &result, BVHFrontList *front_list)
Definition: traversal_recurse.cpp:307
coal
Main namespace.
Definition: coal/broadphase/broadphase_bruteforce.h:44
coal::distanceRecurse
void distanceRecurse(DistanceTraversalNodeBase *node, unsigned int b1, unsigned int b2, BVHFrontList *front_list)
Definition: traversal_recurse.cpp:152
coal::distance
COAL_DLLAPI CoalScalar distance(const Matrix3s &R0, const Vec3s &T0, const kIOS &b1, const kIOS &b2, Vec3s *P=NULL, Vec3s *Q=NULL)
Approximate distance between two kIOS bounding volumes.
Definition: kIOS.cpp:180
coal::BVHFrontList
std::list< BVHFrontNode > BVHFrontList
BVH front list is a list of front nodes.
Definition: coal/BVH/BVH_front.h:66
coal::CollisionResult::distance_lower_bound
CoalScalar distance_lower_bound
Definition: coal/collision_data.h:401
COAL_UNUSED_VARIABLE
#define COAL_UNUSED_VARIABLE(var)
Definition: include/coal/fwd.hh:56
coal::distanceQueueRecurse
void distanceQueueRecurse(DistanceTraversalNodeBase *node, unsigned int b1, unsigned int b2, BVHFrontList *front_list, unsigned int qsize)
Definition: traversal_recurse.cpp:241
traversal_recurse.h
coal::CollisionResult
collision result
Definition: coal/collision_data.h:390
coal::CollisionRequest
request to the collision algorithm
Definition: coal/collision_data.h:311
coal::collisionRecurse
void collisionRecurse(CollisionTraversalNodeBase *node, unsigned int b1, unsigned int b2, BVHFrontList *front_list, CoalScalar &sqrDistLowerBound)
Definition: traversal_recurse.cpp:43
coal::collisionNonRecurse
void collisionNonRecurse(CollisionTraversalNodeBase *node, BVHFrontList *front_list, CoalScalar &sqrDistLowerBound)
Definition: traversal_recurse.cpp:86
epsilon
static CoalScalar epsilon
Definition: simple.cpp:12
coal::checkResultLowerBound
void checkResultLowerBound(const CollisionResult &result, CoalScalar sqrDistLowerBound)
Definition: collision_node.cpp:43
coal::collide
COAL_DLLAPI std::size_t collide(const CollisionObject *o1, const CollisionObject *o2, const CollisionRequest &request, CollisionResult &result)
Main collision interface: given two collision objects, and the requirements for contacts,...
Definition: src/collision.cpp:61
coal::CoalScalar
double CoalScalar
Definition: coal/data_types.h:76


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