39 #ifndef HPP_FCL_COLLISION_DATA_H 40 #define HPP_FCL_COLLISION_DATA_H 47 #include <hpp/fcl/config.hh> 91 static const int NONE = -1;
112 penetration_depth(depth_)
118 return b2 < other.
b2;
119 return b1 < other.
b1;
124 return o1 == other.
o1 135 return !(*
this == other);
176 bool enable_contact_ =
false,
177 bool enable_distance_lower_bound_ =
false,
178 size_t num_max_cost_sources_ = 1,
179 bool enable_cost_ =
false,
180 bool use_approximate_cost_ =
true)
184 num_max_contacts(num_max_contacts_),
185 enable_contact(flag &
CONTACT),
188 break_distance (1e-3)
190 enable_cached_gjk_guess =
false;
191 cached_gjk_guess =
Vec3f(1, 0, 0);
196 enable_contact(false),
197 enable_distance_lower_bound (false),
199 break_distance (1e-3)
201 enable_cached_gjk_guess =
false;
202 cached_gjk_guess =
Vec3f(1, 0, 0);
213 std::vector<Contact> contacts;
226 : distance_lower_bound (std::numeric_limits<
FCL_REAL>::max())
233 if (distance_lower_bound_ < distance_lower_bound)
234 distance_lower_bound = distance_lower_bound_;
240 contacts.push_back(c);
246 return contacts == other.contacts
253 return contacts.size() > 0;
259 return contacts.size();
265 if(contacts.size() == 0)
266 throw std::invalid_argument(
"The number of contacts is zero. No Contact can be returned.");
268 if(i < contacts.size())
271 return contacts.back();
277 contacts_.resize(contacts.size());
278 std::copy(contacts.begin(), contacts.end(), contacts_.begin());
310 enable_nearest_points(enable_nearest_points_),
322 enable_nearest_points(enable_nearest_points_),
369 std::numeric_limits<FCL_REAL>::max()):
370 min_distance(min_distance_), o1(NULL), o2(NULL), b1(NONE), b2(NONE)
372 Vec3f nan (Vec3f::Constant(std::numeric_limits<FCL_REAL>::quiet_NaN()));
373 nearest_points [0] = nearest_points [1] = normal = nan;
380 if(min_distance > distance)
395 if(min_distance > distance)
402 nearest_points[0] = p1;
403 nearest_points[1] = p2;
414 o1 = other_result.
o1;
415 o2 = other_result.
o2;
416 b1 = other_result.
b1;
417 b2 = other_result.
b2;
420 normal = other_result.
normal;
427 min_distance = std::numeric_limits<FCL_REAL>::max();
446 if ((o1 != NULL) xor (other.
o1 != NULL))
return false;
447 is_same &= (o1 == other.
o1);
450 if ((o2 != NULL) xor (other.
o2 != NULL))
return false;
451 is_same &= (o2 == other.
o2);
464 {
return static_cast<CollisionRequestFlag>(
static_cast<const int>(a) | static_cast<const int>(b));}
467 {
return static_cast<CollisionRequestFlag>(
static_cast<const int>(a) & static_cast<const int>(b));}
470 {
return static_cast<CollisionRequestFlag>(
static_cast<const int>(a) ^ static_cast<const int>(b));}
size_t num_max_contacts
The maximum number of contacts will return.
Definition: collision_data.h:153
CollisionRequestFlag operator|(CollisionRequestFlag a, CollisionRequestFlag b)
Definition: collision_data.h:463
DistanceRequest(bool enable_nearest_points_, FCL_REAL rel_err_, FCL_REAL abs_err_, int) HPP_FCL_DEPRECATED
Definition: collision_data.h:306
const int GST_INDEP HPP_FCL_DEPRECATED
Definition: collision_data.h:56
request to the distance computation
Definition: collision_data.h:296
void update(const DistanceResult &other_result)
add distance information into the result
Definition: collision_data.h:409
const CollisionGeometry * o1
collision object 1
Definition: collision_data.h:348
Main namespace.
Definition: AABB.h:43
collision result
Definition: collision_data.h:209
int b2
information about the nearest point in object 2 if object 2 is mesh or point cloud, it is the triangle or point id if object 2 is geometry shape, it is NONE (-1), if object 2 is octree, it is the id of the cell
Definition: collision_data.h:363
Vec3f nearest_points[2]
nearest points
Definition: collision_data.h:342
void updateDistanceLowerBound(const FCL_REAL &distance_lower_bound_)
Update the lower bound only if the distance in inferior.
Definition: collision_data.h:231
CollisionRequestFlag & operator|=(CollisionRequestFlag &a, CollisionRequestFlag b)
Definition: collision_data.h:472
size_t numContacts() const
number of contacts found
Definition: collision_data.h:257
void addContact(const Contact &c)
add one contact into result structure
Definition: collision_data.h:238
DistanceResult(FCL_REAL min_distance_=std::numeric_limits< FCL_REAL >::max())
Definition: collision_data.h:368
FCL_REAL distance_lower_bound
Definition: collision_data.h:222
Definition: collision_data.h:144
void clear()
clear the result
Definition: collision_data.h:425
CollisionRequestFlag & operator &=(CollisionRequestFlag &a, CollisionRequestFlag b)
Definition: collision_data.h:475
CollisionRequestFlag
flag declaration for specifying required params in CollisionResult
Definition: collision_data.h:142
CollisionRequestFlag operator^(CollisionRequestFlag a, CollisionRequestFlag b)
Definition: collision_data.h:469
request to the collision algorithm
Definition: collision_data.h:150
void clear()
clear the results obtained
Definition: collision_data.h:282
FCL_REAL distance(const Matrix3f &R0, const Vec3f &T0, const kIOS &b1, const kIOS &b2, Vec3f *P=NULL, Vec3f *Q=NULL)
Approximate distance between two kIOS bounding volumes.
double FCL_REAL
Definition: data_types.h:68
CollisionRequestFlag & operator^=(CollisionRequestFlag &a, CollisionRequestFlag b)
Definition: collision_data.h:478
FCL_REAL min_distance
minimum distance between two objects. if two objects are in collision, min_distance <= 0...
Definition: collision_data.h:339
int b1
information about the nearest point in object 1 if object 1 is mesh or point cloud, it is the triangle or point id if object 1 is geometry shape, it is NONE (-1), if object 1 is octree, it is the id of the cell
Definition: collision_data.h:357
Vec3f normal
In case both objects are in collision, store the normal.
Definition: collision_data.h:345
void getContacts(std::vector< Contact > &contacts_) const
get all the contacts
Definition: collision_data.h:275
Vec3f cached_gjk_guess
Definition: collision_data.h:216
FCL_REAL break_distance
Distance below which bounding volumes are broken down. See Collision detection and distance lower bou...
Definition: collision_data.h:173
FCL_REAL rel_err
error threshold for approximate distance
Definition: collision_data.h:302
CollisionRequest()
Definition: collision_data.h:194
bool enable_nearest_points
whether to return the nearest points
Definition: collision_data.h:299
bool enable_distance_lower_bound
Whether a lower bound on distance is returned when objects are disjoint.
Definition: collision_data.h:159
Vec3f cached_gjk_guess
the gjk intial guess set by user
Definition: collision_data.h:165
CollisionResult()
Definition: collision_data.h:225
const Contact & getContact(size_t i) const
get the i-th contact calculated
Definition: collision_data.h:263
CollisionRequestFlag operator &(CollisionRequestFlag a, CollisionRequestFlag b)
Definition: collision_data.h:466
Definition: collision_data.h:145
bool enable_contact
whether the contact information (normal, penetration depth and contact position) will return ...
Definition: collision_data.h:156
bool isCollision() const
return binary collision result
Definition: collision_data.h:251
bool enable_cached_gjk_guess
whether enable gjk intial guess
Definition: collision_data.h:162
CollisionRequestFlag operator~(CollisionRequestFlag a)
Definition: collision_data.h:460
Definition: collision_data.h:146
Eigen::Matrix< FCL_REAL, 3, 1 > Vec3f
Definition: data_types.h:73
void update(FCL_REAL distance, const CollisionGeometry *o1_, const CollisionGeometry *o2_, int b1_, int b2_)
add distance information into the result
Definition: collision_data.h:378
void update(FCL_REAL distance, const CollisionGeometry *o1_, const CollisionGeometry *o2_, int b1_, int b2_, const Vec3f &p1, const Vec3f &p2, const Vec3f &normal_)
add distance information into the result
Definition: collision_data.h:391
The geometry for the object for collision or distance computation.
Definition: collision_object.h:63
FCL_REAL abs_err
Definition: collision_data.h:303
const CollisionGeometry * o2
collision object 2
Definition: collision_data.h:351
DistanceRequest(bool enable_nearest_points_=false, FCL_REAL rel_err_=0.0, FCL_REAL abs_err_=0.0)
Definition: collision_data.h:319
distance result
Definition: collision_data.h:333
FCL_REAL security_margin
Distance below which objects are considered in collision. See Collision detection and distance lower ...
Definition: collision_data.h:169