-
Notifications
You must be signed in to change notification settings - Fork 137
Open
Description
In this example, collision checking with positive security margin with broadphase has incorrect result.
#include <coal/broadphase/broadphase_dynamic_AABB_tree.h>
#include <coal/broadphase/default_broadphase_callbacks.h>
#include <coal/shape/geometric_shapes.h>
int main() {
// Create a box
auto box1 = std::make_shared<coal::Box>(0.16, 0.27, 0.37);
auto obj1 = std::make_shared<coal::CollisionObject>(box1);
coal::Transform3s trans1;
trans1.rotation() << 0, -1, 0, 0, 0, 1, -1, 0, 0;
trans1.translation() << 1.490670, 0.845416, -0.194226;
obj1->setTransform(trans1);
obj1->computeAABB();
// Create another box
auto box2 = std::make_shared<coal::Box>(5.898, 0.06, 2.69);
auto obj2 = std::make_shared<coal::CollisionObject>(box2);
coal::Transform3s trans2;
trans2.rotation() << 1, 0, 0, 0, 1, 0, 0, 0, 1;
// trans2.rotation() << 0.9998477, -0.0174524, 0.0000000, 0.0174524,
// 0.9998477, 0.0000000, 0.0000000, 0.0000000, 1.0000000;
trans2.translation() << 0.000000, 1.075000, 0.555000;
obj2->setTransform(trans2);
obj2->computeAABB();
// Setup collision manager
coal::DynamicAABBTreeCollisionManager manager1;
manager1.registerObject(obj1.get());
manager1.setup();
coal::DynamicAABBTreeCollisionManager manager2;
manager2.registerObject(obj2.get());
manager2.setup();
// Distance check using broadphase
coal::DistanceCallBackDefault distance_callback;
manager1.distance(&manager2, &distance_callback);
std::cout << "Distance: " << distance_callback.data.result.min_distance
<< std::endl;
// Collision check with broadphase
coal::CollisionCallBackDefault collision_callback;
collision_callback.data.request.security_margin = 0.04;
manager1.collide(&manager2, &collision_callback);
std::cout << "Collision with broadphase: "
<< collision_callback.data.result.isCollision() << std::endl;
// Collision check without broadphase
coal::CollisionRequest request;
request.security_margin = 0.04;
coal::CollisionResult result;
coal::collide(obj1.get(), obj2.get(), request, result);
std::cout << "Collision without broadphase: " << result.isCollision()
<< std::endl;
return 0;
}
Output
Distance: 0.014584
Collision with broadphase: 0
Collision without broadphase: 1
# Rotate trans2 by 1 deg
Distance: 0.0382369
Collision with broadphase: 1
Collision without broadphase: 1
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels