collision.h
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  * Copyright (c) 2021, INRIA
7  * All rights reserved.
8  *
9  * Redistribution and use in source and binary forms, with or without
10  * modification, are permitted provided that the following conditions
11  * are met:
12  *
13  * * Redistributions of source code must retain the above copyright
14  * notice, this list of conditions and the following disclaimer.
15  * * Redistributions in binary form must reproduce the above
16  * copyright notice, this list of conditions and the following
17  * disclaimer in the documentation and/or other materials provided
18  * with the distribution.
19  * * Neither the name of Open Source Robotics Foundation nor the names of its
20  * contributors may be used to endorse or promote products derived
21  * from this software without specific prior written permission.
22  *
23  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
26  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
27  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
28  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
29  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
31  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
33  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
34  * POSSIBILITY OF SUCH DAMAGE.
35  */
36 
39 #ifndef HPP_FCL_COLLISION_H
40 #define HPP_FCL_COLLISION_H
41 
42 #include <hpp/fcl/data_types.h>
44 #include <hpp/fcl/collision_data.h>
46 #include <hpp/fcl/timings.h>
47 
48 namespace hpp {
49 namespace fcl {
50 
58 HPP_FCL_DLLAPI std::size_t collide(const CollisionObject* o1,
59  const CollisionObject* o2,
60  const CollisionRequest& request,
61  CollisionResult& result);
62 
65 HPP_FCL_DLLAPI std::size_t collide(const CollisionGeometry* o1,
66  const Transform3f& tf1,
67  const CollisionGeometry* o2,
68  const Transform3f& tf2,
69  const CollisionRequest& request,
70  CollisionResult& result);
71 
76 inline std::size_t collide(const CollisionObject* o1, const CollisionObject* o2,
77  CollisionRequest& request, CollisionResult& result) {
78  std::size_t res = collide(o1, o2, (const CollisionRequest&)request, result);
79  request.updateGuess(result);
80  return res;
81 }
82 
87 inline std::size_t collide(const CollisionGeometry* o1, const Transform3f& tf1,
88  const CollisionGeometry* o2, const Transform3f& tf2,
89  CollisionRequest& request, CollisionResult& result) {
90  std::size_t res =
91  collide(o1, tf1, o2, tf2, (const CollisionRequest&)request, result);
92  request.updateGuess(result);
93  return res;
94 }
95 
103 class HPP_FCL_DLLAPI ComputeCollision {
104  public:
107 
108  std::size_t operator()(const Transform3f& tf1, const Transform3f& tf2,
109  const CollisionRequest& request,
110  CollisionResult& result) const;
111 
112  inline std::size_t operator()(const Transform3f& tf1, const Transform3f& tf2,
113  CollisionRequest& request,
114  CollisionResult& result) const {
115  std::size_t res = operator()(tf1, tf2, (const CollisionRequest&)request,
116  result);
117  request.updateGuess(result);
118  return res;
119  }
120 
121  bool operator==(const ComputeCollision& other) const {
122  return o1 == other.o1 && o2 == other.o2 && solver == other.solver;
123  }
124 
125  bool operator!=(const ComputeCollision& other) const {
126  return !(*this == other);
127  }
128 
129  virtual ~ComputeCollision(){};
130 
131  protected:
132  // These pointers are made mutable to let the derived classes to update
133  // their values when updating the collision geometry (e.g. creating a new
134  // one). This feature should be used carefully to avoid any mis usage (e.g,
135  // changing the type of the collision geometry should be avoided).
136  mutable const CollisionGeometry* o1;
137  mutable const CollisionGeometry* o2;
138 
139  mutable GJKSolver solver;
140 
143 
144  virtual std::size_t run(const Transform3f& tf1, const Transform3f& tf2,
145  const CollisionRequest& request,
146  CollisionResult& result) const;
147 
148  public:
149  EIGEN_MAKE_ALIGNED_OPERATOR_NEW
150 };
151 
152 } // namespace fcl
153 } // namespace hpp
154 
155 #endif
Simple transform class used locally by InterpMotion.
Definition: transform.h:54
Main namespace.
tuple tf2
const CollisionGeometry * o1
Definition: collision.h:129
std::size_t(* CollisionFunc)(const CollisionGeometry *o1, const Transform3f &tf1, const CollisionGeometry *o2, const Transform3f &tf2, const GJKSolver *nsolver, const CollisionRequest &request, CollisionResult &result)
the uniform call interface for collision: for collision, we need know
bool operator!=(const ComputeCollision &other) const
Definition: collision.h:125
request to the collision algorithm
HPP_FCL_COMPILER_DIAGNOSTIC_POP void updateGuess(const QueryResult &result)
This class reduces the cost of identifying the geometry pair. This is mostly useful for repeated shap...
Definition: collision.h:103
bool operator==(const ComputeCollision &other) const
Definition: collision.h:121
res
HPP_FCL_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, including num of max contacts, whether perform exhaustive collision (i.e., returning returning all the contact points), whether return detailed contact information (i.e., normal, contact point, depth; otherwise only contact primitive id is returned), this function performs the collision between them. Return value is the number of contacts generated between the two objects.
std::size_t operator()(const Transform3f &tf1, const Transform3f &tf2, CollisionRequest &request, CollisionResult &result) const
Definition: collision.h:112
CollisionFunctionMatrix::CollisionFunc func
Definition: collision.h:141
const CollisionGeometry * o2
Definition: collision.h:137
collision and distance solver based on GJK algorithm implemented in fcl (rewritten the code from the ...
Definition: narrowphase.h:54
the object for collision or distance computation, contains the geometry and the transform information...
The geometry for the object for collision or distance computation.
tuple tf1


hpp-fcl
Author(s):
autogenerated on Fri Jun 2 2023 02:39:00