humanoid-path-planner / hpp-fcl

An extension of the Flexible Collision Library
Other
306 stars 90 forks source link

Incorrect collision detection result #609

Closed mangenhe closed 2 months ago

mangenhe commented 3 months ago

Hello, thank you for your work! During my testing, I found that the results detected by the hpp-fcl library have some significant errors, but the original fcl library can perform precise collision detection.

The images below show the detection results of two objects using both libraries. The first image displays the results from the original fcl library, while the second image shows the results from the hpp-fcl library. When the circular base is red, it indicates a collision. fcl hpp-fcl It is evident that hpp-fcl detects collisions even when they do not actually collide. Additionally, I have confirmed that both hpp-fcl and fcl use the same model pose transformations.

I created the model from an STL file. Below is the code for creating the collision object and detecting collisions.

std::shared_ptr<hpp::fcl::CollisionObject> loadConvexMesh(const std::string& file_name){
    hpp::fcl::NODE_TYPE bv_type = hpp::fcl::BV_OBBRSS;
    hpp::fcl::MeshLoader loader(bv_type);
    hpp::fcl::BVHModelPtr_t bvh = loader.load(file_name);
    bvh->buildConvexHull(true, "Qt");
    return std::make_shared<hpp::fcl::CollisionObject>(bvh->convex);
}
bool ArmGL::detectCollision(std::shared_ptr<hpp::fcl::CollisionObject> obj1, std::shared_ptr<hpp::fcl::CollisionObject> obj2){
    hpp::fcl::CollisionRequest col_req;
    col_req.num_max_contacts = 1;
    hpp::fcl::CollisionResult col_res;
    hpp::fcl::collide(obj1.get(), obj2.get(), col_req, col_res);
    bool res = col_res.isCollision();
    if (res){
        hpp::fcl::Contact contact = col_res.getContact(0);
        qDebug() << "Contact Size: " << col_res.numContacts() ;
        qDebug() << "Penetration depth: " << contact.penetration_depth ;
        qDebug() << "Distance between the shapes including the security margin: " << contact.penetration_depth + col_req.security_margin ;
    }
    else{
        qDebug() << "hppfcl : No collision detected." ;
    }
    return res;
}
jcarpent commented 3 months ago

Could you share a full reproducible pipeline? Including mesh files

mangenhe commented 3 months ago

I can share another simple Qt program to reproduce this issue, but I'll need some time to organize the code. Also, I suspect my issue may be related to using a non-convex model file.

mangenhe commented 3 months ago

Link.zip These are the two mesh files I used for testing.

jcarpent commented 3 months ago

@lmontaut Could you have a look to this issue?

lmontaut commented 3 months ago

Hi @mangenhe, could you provide the poses of the objects for which you are encountering an issue?