38 #ifndef HPP_FCL_COLLISION_OBJECT_BASE_H
39 #define HPP_FCL_COLLISION_OBJECT_BASE_H
98 : aabb_center(
Vec3f::Constant((std::numeric_limits<
FCL_REAL>::max)())),
101 threshold_occupied(1),
124 return isNotEqual(other);
143 inline bool isOccupied()
const {
return cost_density >= threshold_occupied; }
146 inline bool isFree()
const {
return cost_density <= threshold_free; }
178 return Matrix3f::Constant(NAN);
186 Matrix3f C = computeMomentofInertia();
187 Vec3f com = computeCOM();
190 return (
Matrix3f() << C(0, 0) - V * (com[1] * com[1] + com[2] * com[2]),
191 C(0, 1) + V * com[0] * com[1], C(0, 2) + V * com[0] * com[2],
192 C(1, 0) + V * com[1] * com[0],
193 C(1, 1) - V * (com[0] * com[0] + com[2] * com[2]),
194 C(1, 2) + V * com[1] * com[2], C(2, 0) + V * com[2] * com[0],
195 C(2, 1) + V * com[2] * com[1],
196 C(2, 2) - V * (com[0] * com[0] + com[1] * com[1]))
206 return !(*
this == other);
210 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
218 bool compute_local_aabb =
true)
219 : cgeom(cgeom_), user_data(nullptr) {
220 init(compute_local_aabb);
224 const Transform3f& tf,
bool compute_local_aabb =
true)
225 : cgeom(cgeom_), t(tf), user_data(nullptr) {
226 init(compute_local_aabb);
231 bool compute_local_aabb =
true)
232 : cgeom(cgeom_), t(R, T), user_data(nullptr) {
233 init(compute_local_aabb);
237 return cgeom == other.
cgeom && t == other.
t && user_data == other.
user_data;
241 return !(*
this == other);
260 if (t.getRotation().isIdentity()) {
261 aabb =
translate(cgeom->aabb_local, t.getTranslation());
263 aabb.min_ = aabb.max_ = t.getTranslation();
265 Vec3f min_world, max_world;
266 for (
int k = 0; k < 3; ++k) {
267 min_world.array() = t.getRotation().row(k).array() *
268 cgeom->aabb_local.min_.transpose().array();
269 max_world.array() = t.getRotation().row(k).array() *
270 cgeom->aabb_local.max_.transpose().array();
272 aabb.min_[k] += (min_world.array().min)(max_world.array()).sum();
273 aabb.max_[k] += (min_world.array().max)(max_world.array()).sum();
332 const shared_ptr<CollisionGeometry>& collision_geometry,
333 bool compute_local_aabb =
true) {
334 if (collision_geometry.get() != cgeom.get()) {
335 cgeom = collision_geometry;
336 init(compute_local_aabb);
341 void init(
bool compute_local_aabb =
true) {
343 if (compute_local_aabb) cgeom->computeLocalAABB();
348 shared_ptr<CollisionGeometry>
cgeom;
A class describing the AABB collision structure, which is a box in 3D space determined by two diagona...
Definition: AABB.h:56
The geometry for the object for collision or distance computation.
Definition: collision_object.h:95
the object for collision or distance computation, contains the geometry and the transform information
Definition: collision_object.h:215
#define HPP_FCL_DLLAPI
Definition: config.hh:88
KDOP< N > translate(const KDOP< N > &bv, const Vec3f &t)
translate the KDOP BV
virtual Vec3f computeCOM() const
compute center of mass
Definition: collision_object.h:174
const shared_ptr< const CollisionGeometry > collisionGeometry() const
get shared pointer to collision geometry of the object instance
Definition: collision_object.h:312
void * getUserData() const
get user data in geometry
Definition: collision_object.h:137
CollisionObject(const shared_ptr< CollisionGeometry > &cgeom_, const Matrix3f &R, const Vec3f &T, bool compute_local_aabb=true)
Definition: collision_object.h:229
bool isUncertain() const
whether the object has some uncertainty
const Transform3f & getTransform() const
get object's transform
Definition: collision_object.h:291
CollisionGeometry(const CollisionGeometry &other)=default
Copy constructor.
void setCollisionGeometry(const shared_ptr< CollisionGeometry > &collision_geometry, bool compute_local_aabb=true)
Associate a new CollisionGeometry.
Definition: collision_object.h:331
FCL_REAL cost_density
collision cost for unit volume
Definition: collision_object.h:165
const Vec3f & getTranslation() const
get translation of the object
Definition: collision_object.h:285
AABB aabb_local
AABB in local coordinate, used for tight AABB when only translation transform.
Definition: collision_object.h:159
void setUserData(void *data)
set user data in object
Definition: collision_object.h:282
const CollisionGeometry * collisionGeometryPtr() const
get raw pointer to collision geometry of the object instance
Definition: collision_object.h:320
bool isOccupied() const
whether the object is completely occupied
Definition: collision_object.h:143
bool isIdentityTransform() const
whether the object is in local coordinate
Definition: collision_object.h:306
const shared_ptr< CollisionGeometry > & collisionGeometry()
get shared pointer to collision geometry of the object instance
Definition: collision_object.h:317
bool operator!=(const CollisionGeometry &other) const
Difference operator.
Definition: collision_object.h:123
FCL_REAL threshold_occupied
threshold for occupied ( >= is occupied)
Definition: collision_object.h:168
FCL_REAL aabb_radius
AABB radius.
Definition: collision_object.h:155
@ OT_GEOM
Definition: collision_object.h:56
@ OT_OCTREE
Definition: collision_object.h:57
@ OT_HFIELD
Definition: collision_object.h:58
@ OT_BVH
Definition: collision_object.h:55
@ OT_COUNT
Definition: collision_object.h:59
@ OT_UNKNOWN
Definition: collision_object.h:54
virtual CollisionGeometry * clone() const =0
Clone *this into a new CollisionGeometry.
AABB & getAABB()
get the AABB in world space
Definition: collision_object.h:256
void setTransform(const Transform3f &tf)
set object's transform
Definition: collision_object.h:303
virtual OBJECT_TYPE getObjectType() const
get the type of the object
Definition: collision_object.h:128
CollisionGeometry * collisionGeometryPtr()
get raw pointer to collision geometry of the object instance
Definition: collision_object.h:323
void * user_data
pointer to user defined data specific to this object
Definition: collision_object.h:162
FCL_REAL threshold_free
threshold for free (<= is free)
Definition: collision_object.h:171
bool isFree() const
whether the object is completely free
Definition: collision_object.h:146
bool operator==(const CollisionGeometry &other) const
Equality operator.
Definition: collision_object.h:113
void setTranslation(const Vec3f &T)
set object's translation
Definition: collision_object.h:297
@ BV_UNKNOWN
Definition: collision_object.h:66
@ GEOM_TRIANGLE
Definition: collision_object.h:83
@ GEOM_CAPSULE
Definition: collision_object.h:77
@ NODE_COUNT
Definition: collision_object.h:88
@ BV_kIOS
Definition: collision_object.h:70
@ HF_AABB
Definition: collision_object.h:86
@ HF_OBBRSS
Definition: collision_object.h:87
@ BV_KDOP18
Definition: collision_object.h:73
@ GEOM_PLANE
Definition: collision_object.h:81
@ BV_AABB
Definition: collision_object.h:67
@ BV_OBBRSS
Definition: collision_object.h:71
@ GEOM_HALFSPACE
Definition: collision_object.h:82
@ BV_KDOP16
Definition: collision_object.h:72
@ GEOM_ELLIPSOID
Definition: collision_object.h:85
@ GEOM_BOX
Definition: collision_object.h:75
@ BV_OBB
Definition: collision_object.h:68
@ BV_KDOP24
Definition: collision_object.h:74
@ GEOM_CONVEX
Definition: collision_object.h:80
@ GEOM_CYLINDER
Definition: collision_object.h:79
@ GEOM_SPHERE
Definition: collision_object.h:76
@ BV_RSS
Definition: collision_object.h:69
@ GEOM_CONE
Definition: collision_object.h:78
@ GEOM_OCTREE
Definition: collision_object.h:84
void init(bool compute_local_aabb=true)
Definition: collision_object.h:341
void setTransform(const Matrix3f &R, const Vec3f &T)
set object's transform
Definition: collision_object.h:300
virtual Matrix3f computeMomentofInertia() const
compute the inertia matrix, related to the origin
Definition: collision_object.h:177
void * user_data
pointer to user defined data specific to this object
Definition: collision_object.h:356
virtual ~CollisionGeometry()
Definition: collision_object.h:107
bool operator==(const CollisionObject &other) const
Definition: collision_object.h:236
virtual Matrix3f computeMomentofInertiaRelatedToCOM() const
compute the inertia matrix, related to the com
Definition: collision_object.h:185
void computeAABB()
compute the AABB in world space
Definition: collision_object.h:259
virtual FCL_REAL computeVolume() const
compute the volume
Definition: collision_object.h:182
OBJECT_TYPE getObjectType() const
get the type of the object
Definition: collision_object.h:247
void setIdentityTransform()
set the object in local coordinate
Definition: collision_object.h:309
Vec3f aabb_center
AABB center in local coordinate.
Definition: collision_object.h:152
NODE_TYPE getNodeType() const
get the node type
Definition: collision_object.h:250
CollisionObject(const shared_ptr< CollisionGeometry > &cgeom_, const Transform3f &tf, bool compute_local_aabb=true)
Definition: collision_object.h:223
void * getUserData() const
get user data in object
Definition: collision_object.h:279
void setUserData(void *data)
set user data in geometry
Definition: collision_object.h:140
CollisionGeometry()
Definition: collision_object.h:97
virtual void computeLocalAABB()=0
compute the AABB for object in local coordinate
CollisionObject(const shared_ptr< CollisionGeometry > &cgeom_, bool compute_local_aabb=true)
Definition: collision_object.h:217
bool operator!=(const CollisionObject &other) const
Definition: collision_object.h:240
void setRotation(const Matrix3f &R)
set object's rotation matrix
Definition: collision_object.h:294
shared_ptr< CollisionGeometry > cgeom
Definition: collision_object.h:348
const AABB & getAABB() const
get the AABB in world space
Definition: collision_object.h:253
const Matrix3f & getRotation() const
get matrix rotation of the object
Definition: collision_object.h:288
~CollisionObject()
Definition: collision_object.h:244
AABB aabb
AABB in global coordinate.
Definition: collision_object.h:353
virtual NODE_TYPE getNodeType() const
get the node type
Definition: collision_object.h:131
Transform3f t
Definition: collision_object.h:350
Eigen::Matrix< FCL_REAL, 3, 3 > Matrix3f
Definition: data_types.h:71
Eigen::Matrix< FCL_REAL, 3, 1 > Vec3f
Definition: data_types.h:67
OBJECT_TYPE
object type: BVH (mesh, points), basic geometry, octree
Definition: collision_object.h:53
NODE_TYPE
traversal node type: bounding volume (AABB, OBB, RSS, kIOS, OBBRSS, KDOP16, KDOP18,...
Definition: collision_object.h:65
bool isEqual(const Eigen::MatrixBase< Derived > &lhs, const Eigen::MatrixBase< OtherDerived > &rhs, const FCL_REAL tol=std::numeric_limits< FCL_REAL >::epsilon() *100)
Definition: tools.h:205
double FCL_REAL
Definition: data_types.h:66
Main namespace.
Definition: broadphase_bruteforce.h:44