Go to the documentation of this file.
53 : name_(std::move(
name)), config_info_(std::move(config_info)), coll_config_(config_info_)
63 coll_config_.getCollisionAlgorithmCreateFunc(CONVEX_SHAPE_PROXYTYPE, CONVEX_SHAPE_PROXYTYPE));
66 ~btCollisionDispatcher::CD_USE_RELATIVE_CONTACT_BREAKING_THRESHOLD);
95 COW::Ptr new_cow = cow.second->clone();
97 assert(new_cow->getCollisionShape());
98 assert(new_cow->getCollisionShape()->getShapeType() != CUSTOM_CONVEX_SHAPE_TYPE);
100 new_cow->setWorldTransform(cow.second->getWorldTransform());
101 new_cow->setContactProcessingThreshold(margin);
103 manager->addCollisionObject(new_cow);
106 manager->setActiveCollisionObjects(
active_);
123 if (new_cow !=
nullptr)
126 new_cow->setContactProcessingThreshold(margin);
179 it->second->m_enabled =
true;
184 if (it->second->getBroadphaseHandle() !=
nullptr)
185 broadphase_->getOverlappingPairCache()->cleanProxyFromPairs(it->second->getBroadphaseHandle(),
dispatcher_.get());
188 cast_cow->m_enabled =
true;
193 if (cast_cow->getBroadphaseHandle() !=
nullptr)
194 broadphase_->getOverlappingPairCache()->cleanProxyFromPairs(cast_cow->getBroadphaseHandle(),
dispatcher_.get());
207 it->second->m_enabled =
false;
212 if (it->second->getBroadphaseHandle() !=
nullptr)
213 broadphase_->getOverlappingPairCache()->cleanProxyFromPairs(it->second->getBroadphaseHandle(),
dispatcher_.get());
216 cast_cow->m_enabled =
false;
221 if (cast_cow->getBroadphaseHandle() !=
nullptr)
222 broadphase_->getOverlappingPairCache()->cleanProxyFromPairs(cast_cow->getBroadphaseHandle(),
dispatcher_.get());
234 return it->second->m_enabled;
248 cow->setWorldTransform(tf);
252 if (cow->getBroadphaseHandle() !=
nullptr)
260 assert(names.size() == poses.size());
261 for (
auto i = 0U; i < names.size(); ++i)
272 const Eigen::Isometry3d& pose1,
273 const Eigen::Isometry3d& pose2)
286 cow->setWorldTransform(tf1);
292 if (btBroadphaseProxy::isConvex(cow->getCollisionShape()->getShapeType()))
294 assert(
dynamic_cast<CastHullShape*
>(cow->getCollisionShape()) !=
nullptr);
295 static_cast<CastHullShape*
>(cow->getCollisionShape())->updateCastTransform(tf1.inverseTimes(tf2));
297 else if (btBroadphaseProxy::isCompound(cow->getCollisionShape()->getShapeType()))
299 assert(
dynamic_cast<btCompoundShape*
>(cow->getCollisionShape()) !=
nullptr);
300 auto* compound =
static_cast<btCompoundShape*
>(cow->getCollisionShape());
301 for (
int i = 0; i < compound->getNumChildShapes(); ++i)
303 if (btBroadphaseProxy::isConvex(compound->getChildShape(i)->getShapeType()))
305 assert(
dynamic_cast<CastHullShape*
>(compound->getChildShape(i)) !=
nullptr);
306 const btTransform& local_tf = compound->getChildTransform(i);
308 btTransform delta_tf = (tf1 * local_tf).inverseTimes(tf2 * local_tf);
309 static_cast<CastHullShape*
>(compound->getChildShape(i))->updateCastTransform(delta_tf);
310 compound->updateChildTransform(i, local_tf,
false);
312 else if (btBroadphaseProxy::isCompound(compound->getChildShape(i)->getShapeType()))
314 assert(
dynamic_cast<btCompoundShape*
>(compound->getChildShape(i)) !=
nullptr);
315 auto* second_compound =
static_cast<btCompoundShape*
>(compound->getChildShape(i));
317 for (
int j = 0; j < second_compound->getNumChildShapes(); ++j)
319 assert(!btBroadphaseProxy::isCompound(second_compound->getChildShape(j)->getShapeType()));
320 assert(
dynamic_cast<CastHullShape*
>(second_compound->getChildShape(j)) !=
nullptr);
321 const btTransform& local_tf = second_compound->getChildTransform(j);
323 btTransform delta_tf = (tf1 * local_tf).inverseTimes(tf2 * local_tf);
324 static_cast<CastHullShape*
>(second_compound->getChildShape(j))->updateCastTransform(delta_tf);
325 second_compound->updateChildTransform(j, local_tf,
false);
327 second_compound->recalculateLocalAabb();
330 compound->recalculateLocalAabb();
334 throw std::runtime_error(
"I can only continuous collision check convex shapes and compound shapes made of "
349 assert(names.size() == pose1.size());
350 assert(names.size() == pose2.size());
351 for (
auto i = 0U; i < names.size(); ++i)
358 assert(pose1.size() == pose2.size());
359 auto it1 = pose1.begin();
360 auto it2 = pose2.begin();
361 while (it1 != pose1.end())
363 assert(pose1.find(it1->first) != pose2.end());
365 std::advance(it1, 1);
366 std::advance(it2, 1);
461 const std::string& name2,
462 double collision_margin)
469 std::shared_ptr<const tesseract_common::ContactAllowedValidator> validator)
473 std::shared_ptr<const tesseract_common::ContactAllowedValidator>
486 btOverlappingPairCache* pairCache =
broadphase_->getOverlappingPairCache();
511 btVector3 aabb_min, aabb_max;
512 selected_cow->getAABB(aabb_min, aabb_max);
514 int type = selected_cow->getCollisionShape()->getShapeType();
515 selected_cow->setBroadphaseHandle(
broadphase_->createProxy(aabb_min,
519 selected_cow->m_collisionFilterGroup,
520 selected_cow->m_collisionFilterMask,
530 cow->setContactProcessingThreshold(margin);
531 if (cow->getBroadphaseHandle() !=
nullptr)
538 cow->setContactProcessingThreshold(margin);
539 if (cow->getBroadphaseHandle() !=
nullptr)
bool removeCollisionObject(const std::string &name) override final
Remove an object from the checker.
AlignedVector< Eigen::Isometry3d > VectorIsometry3d
void contactTest(ContactResultMap &collisions, const ContactRequest &request) override final
Perform a contact test for all objects based.
void setCollisionMargin(const std::string &obj1, const std::string &obj2, double collision_margin)
void onCollisionMarginDataChanged()
This function will update internal data when margin data has changed.
static const tesseract_common::VectorIsometry3d EMPTY_COLLISION_SHAPES_TRANSFORMS
double getMaxCollisionMargin() const
void setCollisionMarginData(CollisionMarginData collision_margin_data) override final
Set the contact distance threshold.
void setContactAllowedValidator(std::shared_ptr< const tesseract_common::ContactAllowedValidator > validator) override final
Set the active function for determining if two links are allowed to be in collision.
bool addCollisionObject(const std::string &name, const int &mask_id, const CollisionShapesConst &shapes, const tesseract_common::VectorIsometry3d &shape_poses, bool enabled=true) override final
Add a collision object to the checker.
const std::vector< std::string > & getCollisionObjects() const override final
Get all collision objects.
void setCollisionMarginPair(const std::string &name1, const std::string &name2, double collision_margin) override final
Set the margin for a given contact pair.
BulletCastBVHManager(std::string name="BulletCastBVHManager", TesseractCollisionConfigurationInfo config_info=TesseractCollisionConfigurationInfo())
Tesseract ROS Bullet cast(continuous) BVH collision manager.
std::unique_ptr< btCollisionDispatcher > dispatcher_
The bullet collision dispatcher used for getting object to object collison algorithm.
bool disableCollisionObject(const std::string &name) override final
Disable an object.
This is a casted collision shape used for checking if an object is collision free between two transfo...
bool isLinkActive(const std::vector< std::string > &active, const std::string &name)
This will check if a link is active provided a list. If the list is empty the link is considered acti...
AlignedMap< std::string, Eigen::Isometry3d > TransformMap
void incrementCollisionMargin(double increment) override final
Increment the collision margin data by some value.
void updateBroadphaseAABB(const COW::Ptr &cow, const std::unique_ptr< btBroadphaseInterface > &broadphase, const std::unique_ptr< btCollisionDispatcher > &dispatcher)
Update the Broadphase AABB for the input collision object.
TesseractCollisionConfigurationInfo clone() const
Clone the collision configuration information.
static const CollisionShapesConst EMPTY_COLLISION_SHAPES_CONST
COW::Ptr createCollisionObject(const std::string &name, const int &type_id, const CollisionShapesConst &shapes, const tesseract_common::VectorIsometry3d &shape_poses, bool enabled=true)
const CollisionShapesConst & getCollisionObjectGeometries(const std::string &name) const override final
Get a collision objects collision geometries.
template Halfspace< double > transform(const Halfspace< double > &a, const Transform3< double > &tf)
btDispatcherInfo dispatch_info_
The bullet collision dispatcher configuration information.
std::shared_ptr< const tesseract_common::ContactAllowedValidator > getContactAllowedValidator() const override final
Get the active function for determining if two links are allowed to be in collision.
bool collisionCallback(fcl::CollisionObjectd *o1, fcl::CollisionObjectd *o2, void *data)
ContinuousContactManager::UPtr clone() const override final
Clone the manager.
COW::Ptr makeCastCollisionObject(const COW::Ptr &cow)
void addCollisionObjectToBroadphase(const COW::Ptr &cow, const std::unique_ptr< btBroadphaseInterface > &broadphase, const std::unique_ptr< btCollisionDispatcher > &dispatcher)
Add the collision object to broadphase.
A callback function that is called as part of the broadphase collision checking.
const CollisionMarginData & getCollisionMarginData() const override final
Get the contact distance threshold.
void removeCollisionObjectFromBroadphase(const COW::Ptr &cow, const std::unique_ptr< btBroadphaseInterface > &broadphase, const std::unique_ptr< btCollisionDispatcher > &dispatcher)
Remove the collision object from broadphase.
TesseractOverlapFilterCallback broadphase_overlap_cb_
Filter collision objects before broadphase check.
const tesseract_common::VectorIsometry3d & getCollisionObjectGeometriesTransforms(const std::string &name) const override final
Get a collision objects collision geometries transforms.
CollisionMarginPairOverrideType
std::shared_ptr< CollisionObjectWrapper > Ptr
const std::vector< std::string > & getActiveCollisionObjects() const override final
Get which collision objects can move.
std::vector< CollisionShapeConstPtr > CollisionShapesConst
bool enableCollisionObject(const std::string &name) override final
Enable an object.
void apply(const CollisionMarginPairData &pair_margin_data, CollisionMarginPairOverrideType override_type)
void incrementMargins(double increment)
Link2Cow link2cow_
A map of collision objects being managed.
TesseractCollisionConfiguration coll_config_
The bullet collision configuration.
void setDefaultCollisionMargin(double default_collision_margin) override final
Set the default collision margin.
Link2Cow link2castcow_
A map of cast collision objects being managed.
void setCollisionObjectsTransform(const std::string &name, const Eigen::Isometry3d &pose) override final
Set a single static collision object's tansforms.
void setDefaultCollisionMargin(double default_collision_margin)
bool isCollisionObjectEnabled(const std::string &name) const override final
Check if collision object is enabled.
ContactTestData contact_test_data_
This is used when contactTest is called. It is also added as a user point to the collsion objects so ...
bool hasCollisionObject(const std::string &name) const override final
Find if a collision object already exists.
void setCollisionMarginPairData(const CollisionMarginPairData &pair_margin_data, CollisionMarginPairOverrideType override_type=CollisionMarginPairOverrideType::REPLACE) override final
Set the pair contact distance thresholds for which collision should be considered on a per pair basis...
btVector3 convertEigenToBt(const Eigen::Vector3d &v)
TesseractCollisionConfigurationInfo config_info_
The bullet collision configuration information.
void setActiveCollisionObjects(const std::vector< std::string > &names) override final
Set which collision objects can move.
void updateCollisionObjectFilters(const std::vector< std::string > &active, const COW::Ptr &cow)
Update a collision objects filters.
std::vector< std::string > collision_objects_
A list of the collision objects.
std::vector< std::string > active_
A list of the active collision objects.
std::string getName() const override final
Get the name of the contact manager.
std::unique_ptr< btBroadphaseInterface > broadphase_
The bullet broadphase interface.
~BulletCastBVHManager() override
tesseract_common::CollisionMarginData CollisionMarginData