44 for (
const std::pair<const std::string, collision_detection_bullet::CollisionObjectWrapperPtr>& cow :
link2cow_)
46 CollisionObjectWrapperPtr new_cow = cow.second->clone();
48 assert(new_cow->getCollisionShape());
49 assert(new_cow->getCollisionShape()->getShapeType() != CUSTOM_CONVEX_SHAPE_TYPE);
51 new_cow->setWorldTransform(cow.second->getWorldTransform());
53 manager->addCollisionObject(new_cow);
56 manager->setActiveCollisionObjects(
active_);
63 const Eigen::Isometry3d& pose2)
70 CollisionObjectWrapperPtr& cow = it->second;
71 assert(cow->m_collisionFilterGroup == btBroadphaseProxy::KinematicFilter);
76 cow->setWorldTransform(tf1);
82 if (btBroadphaseProxy::isConvex(cow->getCollisionShape()->getShapeType()))
84 static_cast<CastHullShape*
>(cow->getCollisionShape())->updateCastTransform(tf1.inverseTimes(
tf2));
86 else if (btBroadphaseProxy::isCompound(cow->getCollisionShape()->getShapeType()))
88 btCompoundShape* compound =
static_cast<btCompoundShape*
>(cow->getCollisionShape());
90 for (
int i = 0; i < compound->getNumChildShapes(); ++i)
92 if (btBroadphaseProxy::isConvex(compound->getChildShape(i)->getShapeType()))
94 const btTransform& local_tf = compound->getChildTransform(i);
96 btTransform delta_tf = (tf1 * local_tf).inverseTimes(
tf2 * local_tf);
97 static_cast<CastHullShape*
>(compound->getChildShape(i))->updateCastTransform(delta_tf);
98 compound->updateChildTransform(i, local_tf,
false);
100 else if (btBroadphaseProxy::isCompound(compound->getChildShape(i)->getShapeType()))
102 btCompoundShape* second_compound =
static_cast<btCompoundShape*
>(compound->getChildShape(i));
104 for (
int j = 0; j < second_compound->getNumChildShapes(); ++j)
106 assert(!btBroadphaseProxy::isCompound(second_compound->getChildShape(j)->getShapeType()));
107 const btTransform& local_tf = second_compound->getChildTransform(j);
109 btTransform delta_tf = (tf1 * local_tf).inverseTimes(
tf2 * local_tf);
110 static_cast<CastHullShape*
>(second_compound->getChildShape(j))->updateCastTransform(delta_tf);
111 second_compound->updateChildTransform(j, local_tf,
false);
113 second_compound->recalculateLocalAabb();
116 compound->recalculateLocalAabb();
120 ROS_ERROR_NAMED(
"collision_detection.bullet",
"I can only continuous collision check convex shapes and "
121 "compound shapes made of convex shapes");
122 throw std::runtime_error(
123 "I can only continuous collision check convex shapes and compound shapes made of convex shapes");
138 btOverlappingPairCache* pair_cache =
broadphase_->getOverlappingPairCache();
141 "Number overlapping candidates " << pair_cache->getNumOverlappingPairs());
145 pair_cache->processAllOverlappingPairs(&collision_callback,
dispatcher_.get());
150 std::string
name = cow->getName();
151 if (cow->m_collisionFilterGroup == btBroadphaseProxy::KinematicFilter)
161 btVector3 aabb_min, aabb_max;
164 int type =
link2cow_[
name]->getCollisionShape()->getShapeType();