collision_object-inl.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-2016, Open Source Robotics Foundation
6  * All rights reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions
10  * are met:
11  *
12  * * Redistributions of source code must retain the above copyright
13  * notice, this list of conditions and the following disclaimer.
14  * * Redistributions in binary form must reproduce the above
15  * copyright notice, this list of conditions and the following
16  * disclaimer in the documentation and/or other materials provided
17  * with the distribution.
18  * * Neither the name of Open Source Robotics Foundation nor the names of its
19  * contributors may be used to endorse or promote products derived
20  * from this software without specific prior written permission.
21  *
22  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
25  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
26  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
27  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
28  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
29  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
30  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
32  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33  * POSSIBILITY OF SUCH DAMAGE.
34  */
35 
38 #ifndef FCL_COLLISION_OBJECT_INL_H
39 #define FCL_COLLISION_OBJECT_INL_H
40 
42 
43 namespace fcl
44 {
45 
46 //==============================================================================
47 extern template
48 class FCL_EXPORT CollisionObject<double>;
49 
50 //==============================================================================
51 template <typename S>
53  const std::shared_ptr<CollisionGeometry<S>>& cgeom_)
54  : cgeom(cgeom_), cgeom_const(cgeom_), t(Transform3<S>::Identity())
55 {
56  if (cgeom)
57  {
58  cgeom->computeLocalAABB();
59  computeAABB();
60  }
61 }
62 
63 //==============================================================================
64 template <typename S>
66  const std::shared_ptr<CollisionGeometry<S>>& cgeom_,
67  const Transform3<S>& tf)
68  : cgeom(cgeom_), cgeom_const(cgeom_), t(tf)
69 {
70  cgeom->computeLocalAABB();
71  computeAABB();
72 }
73 
74 //==============================================================================
75 template <typename S>
77  const std::shared_ptr<CollisionGeometry<S>>& cgeom_,
78  const Matrix3<S>& R,
79  const Vector3<S>& T)
80  : cgeom(cgeom_), cgeom_const(cgeom_), t(Transform3<S>::Identity())
81 {
82  t.linear() = R;
83  t.translation() = T;
84  cgeom->computeLocalAABB();
85  computeAABB();
86 }
87 
88 //==============================================================================
89 template <typename S>
91 {
92  // Do nothing
93 }
94 
95 //==============================================================================
96 template <typename S>
98 {
99  return cgeom->getObjectType();
100 }
101 
102 //==============================================================================
103 template <typename S>
105 {
106  return cgeom->getNodeType();
107 }
108 
109 //==============================================================================
110 template <typename S>
112 {
113  return aabb;
114 }
115 
116 //==============================================================================
117 template <typename S>
119 {
120  if(t.linear().isIdentity())
121  {
122  aabb = translate(cgeom->aabb_local, t.translation());
123  }
124  else
125  {
126  Vector3<S> center = t * cgeom->aabb_center;
127  Vector3<S> delta = Vector3<S>::Constant(cgeom->aabb_radius);
128  aabb.min_ = center - delta;
129  aabb.max_ = center + delta;
130  }
131 }
132 
133 //==============================================================================
134 template <typename S>
136 {
137  return user_data;
138 }
139 
140 //==============================================================================
141 template <typename S>
143 {
144  user_data = data;
145 }
146 
147 //==============================================================================
148 template <typename S>
150 {
151  return t.translation();
152 }
153 
154 //==============================================================================
155 template <typename S>
157 {
158  return t.linear();
159 }
160 
161 //==============================================================================
162 template <typename S>
164 {
165  return Quaternion<S>(t.linear());
166 }
167 
168 //==============================================================================
169 template <typename S>
171 {
172  return t;
173 }
174 
175 //==============================================================================
176 template <typename S>
178 {
179  t.linear() = R;
180 }
181 
182 //==============================================================================
183 template <typename S>
185 {
186  t.translation() = T;
187 }
188 
189 //==============================================================================
190 template <typename S>
192 {
193  t.linear() = q.toRotationMatrix();
194 }
195 
196 //==============================================================================
197 template <typename S>
199 {
200  setRotation(R);
201  setTranslation(T);
202 }
203 
204 //==============================================================================
205 template <typename S>
207 {
208  setQuatRotation(q);
209  setTranslation(T);
210 }
211 
212 //==============================================================================
213 template <typename S>
215 {
216  t = tf;
217 }
218 
219 //==============================================================================
220 template <typename S>
222 {
223  return t.matrix().isIdentity();
224 }
225 
226 //==============================================================================
227 template <typename S>
229 {
230  t.setIdentity();
231 }
232 
233 //==============================================================================
234 template <typename S>
236 {
237  return cgeom.get();
238 }
239 
240 //==============================================================================
241 template <typename S>
242 const std::shared_ptr<const CollisionGeometry<S>>&
244 {
245  return cgeom_const;
246 }
247 
248 //==============================================================================
249 template <typename S>
251 {
252  return cgeom->cost_density;
253 }
254 
255 //==============================================================================
256 template <typename S>
258 {
259  cgeom->cost_density = c;
260 }
261 
262 //==============================================================================
263 template <typename S>
265 {
266  return cgeom->isOccupied();
267 }
268 
269 //==============================================================================
270 template <typename S>
272 {
273  return cgeom->isFree();
274 }
275 
276 //==============================================================================
277 template <typename S>
279 {
280  return cgeom->isUncertain();
281 }
282 
283 } // namespace fcl
284 
285 #endif
fcl::CollisionObject::setTransform
void setTransform(const Matrix3< S > &R, const Vector3< S > &T)
set object's transform
Definition: collision_object-inl.h:198
fcl::Transform3
Eigen::Transform< S, 3, Eigen::Isometry > Transform3
Definition: types.h:91
fcl::CollisionObject::setIdentityTransform
void setIdentityTransform()
set the object in local coordinate
Definition: collision_object-inl.h:228
fcl::CollisionObject::computeAABB
void computeAABB()
compute the AABB in world space
Definition: collision_object-inl.h:118
collision_object.h
fcl::CollisionObject::getCostDensity
S getCostDensity() const
get object's cost density
Definition: collision_object-inl.h:250
fcl::CollisionObject::getQuatRotation
const Quaternion< S > getQuatRotation() const
get quaternion rotation of the object
Definition: collision_object-inl.h:163
fcl::Quaternion
Eigen::Quaternion< S > Quaternion
Definition: types.h:88
fcl::CollisionObject::isUncertain
bool isUncertain() const
whether the object is uncertain
Definition: collision_object-inl.h:278
fcl::translate
AABB< S > translate(const AABB< S > &aabb, const Eigen::MatrixBase< Derived > &t)
translate the center of AABB by t
Definition: AABB-inl.h:345
fcl::CollisionObject::getNodeType
NODE_TYPE getNodeType() const
get the node type
Definition: collision_object-inl.h:104
fcl::CollisionObject::isOccupied
bool isOccupied() const
whether the object is completely occupied
Definition: collision_object-inl.h:264
fcl::CollisionObject::t
Transform3< S > t
Definition: collision_object.h:146
fcl::AABB< S >
fcl::CollisionObject::getObjectType
OBJECT_TYPE getObjectType() const
get the type of the object
Definition: collision_object-inl.h:97
fcl::Vector3
Eigen::Matrix< S, 3, 1 > Vector3
Definition: types.h:70
fcl::Matrix3
Eigen::Matrix< S, 3, 3 > Matrix3
Definition: types.h:85
fcl::CollisionObject::setRotation
void setRotation(const Matrix3< S > &R)
set object's rotation matrix
Definition: collision_object-inl.h:177
fcl::CollisionGeometry
The geometry for the object for collision or distance computation.
Definition: collision_geometry.h:58
fcl::CollisionObject::getCollisionGeometry
const FCL_DEPRECATED CollisionGeometry< S > * getCollisionGeometry() const
get geometry from the object instance
Definition: collision_object-inl.h:235
fcl::CollisionObject::getRotation
const Matrix3< S > getRotation() const
get matrix rotation of the object
Definition: collision_object-inl.h:156
fcl::CollisionObject::setUserData
void setUserData(void *data)
set user data in object
Definition: collision_object-inl.h:142
fcl::CollisionObject::~CollisionObject
~CollisionObject()
Definition: collision_object-inl.h:90
fcl::CollisionObject::collisionGeometry
const std::shared_ptr< const CollisionGeometry< S > > & collisionGeometry() const
get geometry from the object instance
Definition: collision_object-inl.h:243
fcl::CollisionObject::CollisionObject
CollisionObject(const std::shared_ptr< CollisionGeometry< S >> &cgeom)
Definition: collision_object-inl.h:52
fcl::CollisionObject::getUserData
void * getUserData() const
get user data in object
Definition: collision_object-inl.h:135
fcl::CollisionObject::setQuatRotation
void setQuatRotation(const Quaternion< S > &q)
set object's quatenrion rotation
Definition: collision_object-inl.h:191
fcl::CollisionObject::getTranslation
const Vector3< S > getTranslation() const
get translation of the object
Definition: collision_object-inl.h:149
fcl::OBJECT_TYPE
OBJECT_TYPE
object type: BVH (mesh, points), basic geometry, octree
Definition: collision_geometry.h:50
fcl::CollisionObject::getTransform
const Transform3< S > & getTransform() const
get object's transform
Definition: collision_object-inl.h:170
fcl::CollisionObject< double >
template class FCL_EXPORT CollisionObject< double >
fcl::CollisionObject::getAABB
const AABB< S > & getAABB() const
get the AABB in world space
Definition: collision_object-inl.h:111
fcl::CollisionObject::isIdentityTransform
bool isIdentityTransform() const
whether the object is in local coordinate
Definition: collision_object-inl.h:221
fcl::CollisionObject::setCostDensity
void setCostDensity(S c)
set object's cost density
Definition: collision_object-inl.h:257
fcl::CollisionObject::setTranslation
void setTranslation(const Vector3< S > &T)
set object's translation
Definition: collision_object-inl.h:184
aabb
SaPCollisionManager< S >::SaPAABB * aabb
back pointer to SAP interval
Definition: broadphase_SaP.h:184
fcl::CollisionObject::cgeom
std::shared_ptr< CollisionGeometry< S > > cgeom
Definition: collision_object.h:143
fcl::NODE_TYPE
NODE_TYPE
traversal node type: bounding volume (AABB, OBB, RSS, kIOS, OBBRSS, KDOP16, KDOP18,...
Definition: collision_geometry.h:53
fcl::CollisionObject::isFree
bool isFree() const
whether the object is completely free
Definition: collision_object-inl.h:271
fcl
Main namespace.
Definition: broadphase_bruteforce-inl.h:45


fcl
Author(s):
autogenerated on Tue Dec 5 2023 03:40:48