47 #include <fcl/geometry/shape/plane-inl.h>
64 return std::make_shared<fcl::Planed>(geom->getA(), geom->getB(), geom->getC(), geom->getD());
69 return std::make_shared<fcl::Boxd>(geom->getX(), geom->getY(), geom->getZ());
74 return std::make_shared<fcl::Sphered>(geom->getRadius());
79 return std::make_shared<fcl::Cylinderd>(geom->getRadius(), geom->getLength());
84 return std::make_shared<fcl::Coned>(geom->getRadius(), geom->getLength());
89 return std::make_shared<fcl::Capsuled>(geom->getRadius(), geom->getLength());
94 int vertice_count = geom->getVertexCount();
95 int triangle_count = geom->getFaceCount();
97 const Eigen::VectorXi& triangles = *(geom->getFaces());
99 auto g = std::make_shared<fcl::BVHModel<fcl::OBBRSSd>>();
100 if (vertice_count > 0 && triangle_count > 0)
102 std::vector<fcl::Triangle> tri_indices(
static_cast<size_t>(triangle_count));
103 for (
int i = 0; i < triangle_count; ++i)
105 assert(triangles[4L * i] == 3);
106 tri_indices[
static_cast<size_t>(i)] =
fcl::Triangle(
static_cast<size_t>(triangles[(4 * i) + 1]),
107 static_cast<size_t>(triangles[(4 * i) + 2]),
108 static_cast<size_t>(triangles[(4 * i) + 3]));
112 g->addSubModel(vertices, tri_indices);
118 CONSOLE_BRIDGE_logError(
"The mesh is empty!");
124 int vertice_count = geom->getVertexCount();
125 int face_count = geom->getFaceCount();
127 if (vertice_count > 0 && face_count > 0)
129 auto faces = std::make_shared<const std::vector<int>>(geom->getFaces()->data(),
130 geom->getFaces()->data() + geom->getFaces()->size());
131 return std::make_shared<fcl::Convexd>(geom->getVertices(), face_count, faces);
134 CONSOLE_BRIDGE_logError(
"The mesh is empty!");
140 switch (geom->getSubType())
144 return std::make_shared<fcl::OcTreed>(geom->getOctree());
148 CONSOLE_BRIDGE_logError(
"This fcl octree sub shape type (%d) is not supported for geometry octree",
149 static_cast<int>(geom->getSubType()));
157 switch (geom->getType())
173 return createShapePrimitive(std::static_pointer_cast<const tesseract_geometry::Cylinder>(geom));
189 return createShapePrimitive(std::static_pointer_cast<const tesseract_geometry::ConvexMesh>(geom));
197 throw std::runtime_error(
"CompundMesh type should not be passed to this function!");
201 CONSOLE_BRIDGE_logError(
"This geometric shape type (%d) is not supported using fcl yet",
202 static_cast<int>(geom->getType()));
211 if (shape !=
nullptr)
229 bool needs_collision = cd1->
m_enabled && cd2->m_enabled &&
230 (cd1->m_collisionFilterGroup & cd2->m_collisionFilterMask) &&
231 (cd2->m_collisionFilterGroup & cd1->m_collisionFilterMask) &&
234 assert(std::find(cdata->active->begin(), cdata->active->end(), cd1->getName()) != cdata->active->end() ||
235 std::find(cdata->active->begin(), cdata->active->end(), cd2->getName()) != cdata->active->end());
237 if (!needs_collision)
240 std::size_t num_contacts = (cdata->req.contact_limit > 0) ?
static_cast<std::size_t
>(cdata->req.contact_limit) :
241 std::numeric_limits<std::size_t>::max();
250 const Eigen::Isometry3d& tf1 = cd1->getCollisionObjectsTransform();
251 const Eigen::Isometry3d& tf2 = cd2->getCollisionObjectsTransform();
252 Eigen::Isometry3d tf1_inv = tf1.inverse();
253 Eigen::Isometry3d tf2_inv = tf2.inverse();
255 for (
size_t i = 0; i < col_result.
numContacts(); ++i)
271 contact.
type_id[0] = cd1->getTypeID();
272 contact.
type_id[1] = cd2->getTypeID();
277 const auto it = cdata->res->find(pc);
278 bool found = (it != cdata->res->end() && !it->second.empty());
297 bool needs_collision = cd1->
m_enabled && cd2->m_enabled &&
298 (cd1->m_collisionFilterGroup & cd2->m_collisionFilterMask) &&
299 (cd2->m_collisionFilterGroup & cd1->m_collisionFilterMask) &&
302 assert(std::find(cdata->active->begin(), cdata->active->end(), cd1->getName()) != cdata->active->end() ||
303 std::find(cdata->active->begin(), cdata->active->end(), cd2->getName()) != cdata->active->end());
305 if (!needs_collision)
312 if (d < cdata->collision_margin_data.getMaxCollisionMargin())
314 const Eigen::Isometry3d& tf1 = cd1->getCollisionObjectsTransform();
315 const Eigen::Isometry3d& tf2 = cd2->getCollisionObjectsTransform();
316 Eigen::Isometry3d tf1_inv = tf1.inverse();
317 Eigen::Isometry3d tf2_inv = tf2.inverse();
332 contact.
type_id[0] = cd1->getTypeID();
333 contact.
type_id[1] = cd2->getTypeID();
341 const auto it = cdata->res->find(pc);
342 bool found = (it != cdata->res->end() && !it->second.empty());
354 : name_(std::move(
name)), type_id_(type_id), shapes_(std::move(shapes)), shape_poses_(std::move(shape_poses))
358 assert(!
name_.empty());
367 for (std::size_t i = 0; i <
shapes_.size(); ++i)
371 const auto& meshes = std::static_pointer_cast<const tesseract_geometry::CompoundMesh>(
shapes_[i])->getMeshes();
372 for (
const auto& mesh : meshes)
375 if (subshape !=
nullptr)
378 auto co = std::make_shared<FCLCollisionObjectWrapper>(subshape);
379 co->setUserData(
this);
380 co->setShapeIndex(
static_cast<int>(i));
391 if (subshape !=
nullptr)
394 auto co = std::make_shared<FCLCollisionObjectWrapper>(subshape);
395 co->setUserData(
this);
396 co->setShapeIndex(
static_cast<int>(i));