flexible-collision-library / fcl

Flexible Collision Library
https://flexible-collision-library.github.io/
Other
1.35k stars 415 forks source link

Performance of FCL #616

Open AdmiralPellaeon opened 2 months ago

AdmiralPellaeon commented 2 months ago

Hi,

I have a software for checking collisions within the working area of a machine tool. Atm I use the old library opcode to do the collision check. I also included FCL to give it a try and to have a newer software design. In principle, it works, but I noticed a much slower performance compared to the Opcode library.

I have followed the instructions from the Git homepage. Here is an excerpt of the main parts for using FCL:

auto model = std::make_shared<fcl::BVHModel<fcl::Bounding_box>>();
model->beginModel();
model->addSubModel(vertices, triangles);
model->endModel();

coll_geo = fcl::Collision_object(model);

This is done for every collision object (I have a lot of different geomtries which needs to be checked. It is handled in the struct _Nodefcl.

And this is the actual collision check of two nodes:

bool Collision_detector_fcl::is_collision(Node_fcl& left, Node_fcl& right)
{
    fcl::CollisionResult<fcl::Real_t> result;

    left.coll_geo.setTransform(left.get_full_transformation());
    right.coll_geo.setTransform(right.get_full_transformation());

    fcl::CollisionRequest<fcl::Real_t> request;     
    fcl::collide(&left.coll_geo, &right.coll_geo, request, result);

    return result.isCollision();
}

Perhaps I use the library in an inefficient way? Is there some kind of best practice for FCL if performance is crucial?

Best regards

jcarpent commented 1 month ago

Is your mesh convex?