hpp-fcl  3.0.0
HPP fork of FCL -- The Flexible Collision Library
minkowski_difference.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-2024, 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_MINKOWSKI_DIFFERENCE_H
40 #define HPP_FCL_MINKOWSKI_DIFFERENCE_H
41 
43 #include "hpp/fcl/math/transform.h"
45 
46 namespace hpp {
47 namespace fcl {
48 
49 namespace details {
50 
55  typedef Eigen::Array<FCL_REAL, 1, 2> Array2d;
56 
58  const ShapeBase* shapes[2];
59 
63 
67 
71 
76 
81 
82  typedef void (*GetSupportFunction)(const MinkowskiDiff& minkowskiDiff,
83  const Vec3f& dir, Vec3f& support0,
84  Vec3f& support1,
86  ShapeSupportData data[2]);
87  GetSupportFunction getSupportFunc;
88 
89  MinkowskiDiff() : normalize_support_direction(false), getSupportFunc(NULL) {}
90 
117  template <int _SupportOptions = SupportOptions::NoSweptSphere>
118  void set(const ShapeBase* shape0, const ShapeBase* shape1);
119 
129  template <int _SupportOptions = SupportOptions::NoSweptSphere>
130  void set(const ShapeBase* shape0, const ShapeBase* shape1,
131  const Transform3f& tf0, const Transform3f& tf1);
132 
142  template <int _SupportOptions = SupportOptions::NoSweptSphere>
143  inline Vec3f support0(const Vec3f& dir, int& hint) const {
144  return getSupport<_SupportOptions>(shapes[0], dir, hint);
145  }
146 
159  template <int _SupportOptions = SupportOptions::NoSweptSphere>
160  inline Vec3f support1(const Vec3f& dir, int& hint) const {
161  // clang-format off
162  return oR1 * getSupport<_SupportOptions>(shapes[1], oR1.transpose() * dir, hint) + ot1;
163  // clang-format on
164  }
165 
175  inline void support(const Vec3f& dir, Vec3f& supp0, Vec3f& supp1,
176  support_func_guess_t& hint) const {
177  assert(getSupportFunc != NULL);
178  getSupportFunc(*this, dir, supp0, supp1, hint,
179  const_cast<ShapeSupportData*>(data));
180  }
181 };
182 
183 } // namespace details
184 
185 } // namespace fcl
186 } // namespace hpp
187 
188 #endif // HPP_FCL_MINKOWSKI_DIFFERENCE_H
Base class for all basic geometric shapes.
Definition: geometric_shapes.h:59
Simple transform class used locally by InterpMotion.
Definition: transform.h:56
#define HPP_FCL_DLLAPI
Definition: config.hh:88
Eigen::Matrix< FCL_REAL, 3, 3 > Matrix3f
Definition: data_types.h:71
Eigen::Matrix< FCL_REAL, 3, 1 > Vec3f
Definition: data_types.h:67
Eigen::Vector2i support_func_guess_t
Definition: data_types.h:77
Main namespace.
Definition: broadphase_bruteforce.h:44
Minkowski difference class of two shapes.
Definition: minkowski_difference.h:54
Vec3f ot1
translation from shape1 to shape0 such that .
Definition: minkowski_difference.h:70
void set(const ShapeBase *shape0, const ShapeBase *shape1)
Set the two shapes, assuming the relative transformation between them is identity....
Array2d swept_sphere_radius
The radii of the sphere swepted around each shape of the Minkowski difference. The 2 values correspon...
Definition: minkowski_difference.h:75
void set(const ShapeBase *shape0, const ShapeBase *shape1, const Transform3f &tf0, const Transform3f &tf1)
Set the two shapes, with a relative transformation from shape0 to shape1. Consequently,...
Vec3f support1(const Vec3f &dir, int &hint) const
support function for shape1. The output vector is expressed in the local frame of shape0....
Definition: minkowski_difference.h:160
Matrix3f oR1
rotation from shape1 to shape0 such that .
Definition: minkowski_difference.h:66
Vec3f support0(const Vec3f &dir, int &hint) const
support function for shape0. The output vector is expressed in the local frame of shape0.
Definition: minkowski_difference.h:143
GetSupportFunction getSupportFunc
Definition: minkowski_difference.h:87
void support(const Vec3f &dir, Vec3f &supp0, Vec3f &supp1, support_func_guess_t &hint) const
Support function for the pair of shapes. This method assumes set has already been called.
Definition: minkowski_difference.h:175
MinkowskiDiff()
Definition: minkowski_difference.h:89
bool normalize_support_direction
Wether or not to use the normalize heuristic in the GJK Nesterov acceleration. This setting is only a...
Definition: minkowski_difference.h:80
Eigen::Array< FCL_REAL, 1, 2 > Array2d
Definition: minkowski_difference.h:55
Stores temporary data for the computation of support points.
Definition: support_functions.h:81