38 #ifndef FCL_DISTANCE_FUNC_MATRIX_INL_H 39 #define FCL_DISTANCE_FUNC_MATRIX_INL_H 43 #include "fcl/config.h" 75 #endif // FCL_HAVE_OCTOMAP 85 template <
typename Shape,
typename NarrowPhaseSolver>
86 typename Shape::S ShapeOcTreeDistance(
87 const CollisionGeometry<typename Shape::S>* o1,
88 const Transform3<typename Shape::S>& tf1,
89 const CollisionGeometry<typename Shape::S>* o2,
90 const Transform3<typename Shape::S>& tf2,
91 const NarrowPhaseSolver* nsolver,
92 const DistanceRequest<typename Shape::S>& request,
93 DistanceResult<typename Shape::S>& result)
95 using S =
typename Shape::S;
97 if(request.isSatisfied(result))
return result.min_distance;
98 ShapeOcTreeDistanceTraversalNode<Shape, NarrowPhaseSolver> node;
99 const Shape*
obj1 = static_cast<const Shape*>(o1);
100 const OcTree<S>*
obj2 =
static_cast<const OcTree<S>*
>(o2);
101 OcTreeSolver<NarrowPhaseSolver> otsolver(nsolver);
103 initialize(node, *
obj1, tf1, *obj2, tf2, &otsolver, request, result);
106 return result.min_distance;
109 template <
typename Shape,
typename NarrowPhaseSolver>
110 typename Shape::S OcTreeShapeDistance(
111 const CollisionGeometry<typename Shape::S>* o1,
112 const Transform3<typename Shape::S>& tf1,
113 const CollisionGeometry<typename Shape::S>* o2,
114 const Transform3<typename Shape::S>& tf2,
115 const NarrowPhaseSolver* nsolver,
116 const DistanceRequest<typename Shape::S>& request,
117 DistanceResult<typename Shape::S>& result)
119 using S =
typename Shape::S;
121 if(request.isSatisfied(result))
return result.min_distance;
122 OcTreeShapeDistanceTraversalNode<Shape, NarrowPhaseSolver> node;
123 const OcTree<S>*
obj1 = static_cast<
const OcTree<S>*>(o1);
124 const Shape*
obj2 =
static_cast<const Shape*
>(o2);
125 OcTreeSolver<NarrowPhaseSolver> otsolver(nsolver);
127 initialize(node, *
obj1, tf1, *obj2, tf2, &otsolver, request, result);
130 return result.min_distance;
133 template <
typename NarrowPhaseSolver>
134 typename NarrowPhaseSolver::S OcTreeDistance(
135 const CollisionGeometry<typename NarrowPhaseSolver::S>* o1,
136 const Transform3<typename NarrowPhaseSolver::S>& tf1,
137 const CollisionGeometry<typename NarrowPhaseSolver::S>* o2,
138 const Transform3<typename NarrowPhaseSolver::S>& tf2,
139 const NarrowPhaseSolver* nsolver,
140 const DistanceRequest<typename NarrowPhaseSolver::S>& request,
141 DistanceResult<typename NarrowPhaseSolver::S>& result)
143 using S =
typename NarrowPhaseSolver::S;
145 if(request.isSatisfied(result))
return result.min_distance;
146 OcTreeDistanceTraversalNode<NarrowPhaseSolver> node;
147 const OcTree<S>*
obj1 = static_cast<
const OcTree<S>*>(o1);
148 const OcTree<S>*
obj2 =
static_cast<const OcTree<S>*
>(o2);
149 OcTreeSolver<NarrowPhaseSolver> otsolver(nsolver);
151 initialize(node, *
obj1, tf1, *obj2, tf2, &otsolver, request, result);
154 return result.min_distance;
157 template <
typename BV,
typename NarrowPhaseSolver>
158 typename BV::S BVHOcTreeDistance(
159 const CollisionGeometry<typename BV::S>* o1,
160 const Transform3<typename BV::S>& tf1,
161 const CollisionGeometry<typename BV::S>* o2,
162 const Transform3<typename BV::S>& tf2,
163 const NarrowPhaseSolver* nsolver,
164 const DistanceRequest<typename BV::S>& request,
165 DistanceResult<typename BV::S>& result)
167 using S =
typename BV::S;
169 if(request.isSatisfied(result))
return result.min_distance;
170 MeshOcTreeDistanceTraversalNode<BV, NarrowPhaseSolver> node;
171 const BVHModel<BV>*
obj1 = static_cast<
const BVHModel<BV>*>(o1);
172 const OcTree<S>*
obj2 =
static_cast<const OcTree<S>*
>(o2);
173 OcTreeSolver<NarrowPhaseSolver> otsolver(nsolver);
175 initialize(node, *
obj1, tf1, *obj2, tf2, &otsolver, request, result);
178 return result.min_distance;
181 template <
typename BV,
typename NarrowPhaseSolver>
182 typename BV::S OcTreeBVHDistance(
183 const CollisionGeometry<typename BV::S>* o1,
184 const Transform3<typename BV::S>& tf1,
185 const CollisionGeometry<typename BV::S>* o2,
186 const Transform3<typename BV::S>& tf2,
187 const NarrowPhaseSolver* nsolver,
188 const DistanceRequest<typename BV::S>& request,
189 DistanceResult<typename BV::S>& result)
191 using S =
typename BV::S;
193 if(request.isSatisfied(result))
return result.min_distance;
194 OcTreeMeshDistanceTraversalNode<BV, NarrowPhaseSolver> node;
195 const OcTree<S>*
obj1 = static_cast<
const OcTree<S>*>(o1);
196 const BVHModel<BV>*
obj2 =
static_cast<const BVHModel<BV>*
>(o2);
197 OcTreeSolver<NarrowPhaseSolver> otsolver(nsolver);
199 initialize(node, *
obj1, tf1, *obj2, tf2, &otsolver, request, result);
202 return result.min_distance;
207 template <
typename Shape1,
typename Shape2,
typename NarrowPhaseSolver>
213 const NarrowPhaseSolver* nsolver,
219 const Shape1*
obj1 = static_cast<const Shape1*>(o1);
220 const Shape2*
obj2 =
static_cast<const Shape2*
>(o2);
222 initialize(node, *
obj1, tf1, *obj2, tf2, nsolver, request, result);
228 template <
typename BV,
typename Shape,
typename NarrowPhaseSolver>
231 using S =
typename BV::S;
238 const NarrowPhaseSolver* nsolver,
247 const Shape*
obj2 =
static_cast<const Shape*
>(o2);
249 initialize(node, *obj1_tmp, tf1_tmp, *obj2, tf2, nsolver, request, result);
257 template <
typename OrientedMeshShapeDistanceTraversalNode,
258 typename BV,
typename Shape,
typename NarrowPhaseSolver>
264 const NarrowPhaseSolver* nsolver,
269 OrientedMeshShapeDistanceTraversalNode node;
271 const Shape*
obj2 =
static_cast<const Shape*
>(o2);
273 initialize(node, *
obj1, tf1, *obj2, tf2, nsolver, request, result);
279 template <
typename Shape,
typename NarrowPhaseSolver>
287 const NarrowPhaseSolver* nsolver,
296 o1, tf1, o2, tf2, nsolver, request, result);
300 template <
typename Shape,
typename NarrowPhaseSolver>
308 const NarrowPhaseSolver* nsolver,
317 o1, tf1, o2, tf2, nsolver, request, result);
321 template <
typename Shape,
typename NarrowPhaseSolver>
329 const NarrowPhaseSolver* nsolver,
338 o1, tf1, o2, tf2, nsolver, request, result);
343 template <
typename S,
typename BV>
363 initialize(node, *obj1_tmp, tf1_tmp, *obj2_tmp, tf2_tmp, request, result);
373 template <
typename BV>
383 o1, tf1, o2, tf2, request, result);
386 template <
typename OrientedMeshDistanceTraversalNode,
typename BV>
396 OrientedMeshDistanceTraversalNode node;
407 template <
typename S>
420 o1, tf1, o2, tf2, request, result);
425 template <
typename S>
438 o1, tf1, o2, tf2, request, result);
443 template <
typename S>
456 o1, tf1, o2, tf2, request, result);
461 template <
typename BV,
typename NarrowPhaseSolver>
467 const NarrowPhaseSolver* nsolver,
473 return BVHDistance<BV>(o1, tf1, o2, tf2, request, result);
476 template <
typename NarrowPhaseSolver>
482 distance_matrix[i][j] =
nullptr;
495 distance_matrix[
GEOM_SPHERE][
GEOM_BOX] = &ShapeShapeDistance<Sphere<S>, Box<S>, NarrowPhaseSolver>;
499 distance_matrix[
GEOM_SPHERE][
GEOM_CONE] = &ShapeShapeDistance<Sphere<S>, Cone<S>, NarrowPhaseSolver>;
502 distance_matrix[
GEOM_SPHERE][
GEOM_PLANE] = &ShapeShapeDistance<Sphere<S>, Plane<S>, NarrowPhaseSolver>;
515 distance_matrix[
GEOM_CAPSULE][
GEOM_BOX] = &ShapeShapeDistance<Capsule<S>, Box<S>, NarrowPhaseSolver>;
519 distance_matrix[
GEOM_CAPSULE][
GEOM_CONE] = &ShapeShapeDistance<Capsule<S>, Cone<S>, NarrowPhaseSolver>;
525 distance_matrix[
GEOM_CONE][
GEOM_BOX] = &ShapeShapeDistance<Cone<S>, Box<S>, NarrowPhaseSolver>;
526 distance_matrix[
GEOM_CONE][
GEOM_SPHERE] = &ShapeShapeDistance<Cone<S>, Sphere<S>, NarrowPhaseSolver>;
528 distance_matrix[
GEOM_CONE][
GEOM_CAPSULE] = &ShapeShapeDistance<Cone<S>, Capsule<S>, NarrowPhaseSolver>;
529 distance_matrix[
GEOM_CONE][
GEOM_CONE] = &ShapeShapeDistance<Cone<S>, Cone<S>, NarrowPhaseSolver>;
531 distance_matrix[
GEOM_CONE][
GEOM_CONVEX] = &ShapeShapeDistance<Cone<S>, Convex<S>, NarrowPhaseSolver>;
532 distance_matrix[
GEOM_CONE][
GEOM_PLANE] = &ShapeShapeDistance<Cone<S>, Plane<S>, NarrowPhaseSolver>;
535 distance_matrix[
GEOM_CYLINDER][
GEOM_BOX] = &ShapeShapeDistance<Cylinder<S>, Box<S>, NarrowPhaseSolver>;
545 distance_matrix[
GEOM_CONVEX][
GEOM_BOX] = &ShapeShapeDistance<Convex<S>, Box<S>, NarrowPhaseSolver>;
549 distance_matrix[
GEOM_CONVEX][
GEOM_CONE] = &ShapeShapeDistance<Convex<S>, Cone<S>, NarrowPhaseSolver>;
552 distance_matrix[
GEOM_CONVEX][
GEOM_PLANE] = &ShapeShapeDistance<Convex<S>, Plane<S>, NarrowPhaseSolver>;
555 distance_matrix[
GEOM_PLANE][
GEOM_BOX] = &ShapeShapeDistance<Plane<S>, Box<S>, NarrowPhaseSolver>;
556 distance_matrix[
GEOM_PLANE][
GEOM_SPHERE] = &ShapeShapeDistance<Plane<S>, Sphere<S>, NarrowPhaseSolver>;
559 distance_matrix[
GEOM_PLANE][
GEOM_CONE] = &ShapeShapeDistance<Plane<S>, Cone<S>, NarrowPhaseSolver>;
561 distance_matrix[
GEOM_PLANE][
GEOM_CONVEX] = &ShapeShapeDistance<Plane<S>, Convex<S>, NarrowPhaseSolver>;
562 distance_matrix[
GEOM_PLANE][
GEOM_PLANE] = &ShapeShapeDistance<Plane<S>, Plane<S>, NarrowPhaseSolver>;
660 distance_matrix[
BV_AABB][
BV_AABB] = &BVHDistance<AABB<S>, NarrowPhaseSolver>;
661 distance_matrix[
BV_RSS][
BV_RSS] = &BVHDistance<RSS<S>, NarrowPhaseSolver>;
662 distance_matrix[
BV_kIOS][
BV_kIOS] = &BVHDistance<kIOS<S>, NarrowPhaseSolver>;
688 distance_matrix[
GEOM_OCTREE][
BV_AABB] = &OcTreeBVHDistance<AABB<S>, NarrowPhaseSolver>;
689 distance_matrix[
GEOM_OCTREE][
BV_OBB] = &OcTreeBVHDistance<OBB<S>, NarrowPhaseSolver>;
690 distance_matrix[
GEOM_OCTREE][
BV_RSS] = &OcTreeBVHDistance<RSS<S>, NarrowPhaseSolver>;
692 distance_matrix[
GEOM_OCTREE][
BV_kIOS] = &OcTreeBVHDistance<kIOS<S>, NarrowPhaseSolver>;
697 distance_matrix[
BV_AABB][
GEOM_OCTREE] = &BVHOcTreeDistance<AABB<S>, NarrowPhaseSolver>;
698 distance_matrix[
BV_OBB][
GEOM_OCTREE] = &BVHOcTreeDistance<OBB<S>, NarrowPhaseSolver>;
699 distance_matrix[
BV_RSS][
GEOM_OCTREE] = &BVHOcTreeDistance<RSS<S>, NarrowPhaseSolver>;
701 distance_matrix[
BV_kIOS][
GEOM_OCTREE] = &BVHOcTreeDistance<kIOS<S>, NarrowPhaseSolver>;
S min_distance
Minimum distance between two objects.
static Shape::S distance(const CollisionGeometry< typename Shape::S > *o1, const Transform3< typename Shape::S > &tf1, const CollisionGeometry< typename Shape::S > *o2, const Transform3< typename Shape::S > &tf2, const NarrowPhaseSolver *nsolver, const DistanceRequest< typename Shape::S > &request, DistanceResult< typename Shape::S > &result)
Half Space: this is equivalent to the Planed in ODE. The separation plane is defined as n * x = d...
Traversal node for distance between two shapes.
static S run(const CollisionGeometry< S > *o1, const Transform3< S > &tf1, const CollisionGeometry< S > *o2, const Transform3< S > &tf2, const DistanceRequest< S > &request, DistanceResult< S > &result)
Traversal node for distance between mesh and shape.
Eigen::Transform< S, 3, Eigen::Isometry > Transform3
BV::S orientedMeshDistance(const CollisionGeometry< typename BV::S > *o1, const Transform3< typename BV::S > &tf1, const CollisionGeometry< typename BV::S > *o2, const Transform3< typename BV::S > &tf2, const DistanceRequest< typename BV::S > &request, DistanceResult< typename BV::S > &result)
CollisionObject< S > * obj1
bool isSatisfied(const DistanceResult< S > &result) const
Center at zero point ellipsoid.
S distance(const Eigen::MatrixBase< DerivedA > &R0, const Eigen::MatrixBase< DerivedB > &T0, const kIOS< S > &b1, const kIOS< S > &b2, Vector3< S > *P, Vector3< S > *Q)
Approximate distance between two kIOS bounding volumes.
The geometry for the object for collision or distance computation.
Shape::S orientedBVHShapeDistance(const CollisionGeometry< typename Shape::S > *o1, const Transform3< typename Shape::S > &tf1, const CollisionGeometry< typename Shape::S > *o2, const Transform3< typename Shape::S > &tf2, const NarrowPhaseSolver *nsolver, const DistanceRequest< typename Shape::S > &request, DistanceResult< typename Shape::S > &result)
template bool initialize(MeshCollisionTraversalNodeOBB< double > &node, const BVHModel< OBB< double >> &model1, const Transform3< double > &tf1, const BVHModel< OBB< double >> &model2, const Transform3< double > &tf2, const CollisionRequest< double > &request, CollisionResult< double > &result)
BV::S BVHDistance(const CollisionGeometry< typename BV::S > *o1, const Transform3< typename BV::S > &tf1, const CollisionGeometry< typename BV::S > *o2, const Transform3< typename BV::S > &tf2, const DistanceRequest< typename BV::S > &request, DistanceResult< typename BV::S > &result)
Center at zero point, axis aligned box.
template void distance(DistanceTraversalNodeBase< double > *node, BVHFrontList *front_list, int qsize)
A class describing the bounding hierarchy of a mesh model or a point cloud model (which is viewed as ...
CollisionObject< S > * obj2
Center at zero point sphere.
request to the distance computation
static S run(const CollisionGeometry< S > *o1, const Transform3< S > &tf1, const CollisionGeometry< S > *o2, const Transform3< S > &tf2, const DistanceRequest< S > &request, DistanceResult< S > &result)
A class describing the kIOS collision structure, which is a set of spheres.
static S distance(const CollisionGeometry< S > *o1, const Transform3< S > &tf1, const CollisionGeometry< S > *o2, const Transform3< S > &tf2, const NarrowPhaseSolver *nsolver, const DistanceRequest< S > &request, DistanceResult< S > &result)
Traversal node for distance computation between two meshes.
Shape1::S ShapeShapeDistance(const CollisionGeometry< typename Shape1::S > *o1, const Transform3< typename Shape1::S > &tf1, const CollisionGeometry< typename Shape1::S > *o2, const Transform3< typename Shape1::S > &tf2, const NarrowPhaseSolver *nsolver, const DistanceRequest< typename Shape1::S > &request, DistanceResult< typename Shape1::S > &result)