Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using fcl::Convexd meshes with broadphase collision managers #583

Open
JeffHough opened this issue Aug 30, 2022 · 1 comment
Open

Using fcl::Convexd meshes with broadphase collision managers #583

JeffHough opened this issue Aug 30, 2022 · 1 comment

Comments

@JeffHough
Copy link

I'm currently using FCL to perform collision detection on non-convex shapes, which I have broken down into several convex meshes. I then group together these convex meshes into fcl::BVHModel<fcl::OBBRSSd> models to create rigid bodies, and perform the collision checks using the fcl::DynamicAABBTreeCollisionManagerd broadphase collision manager (these are the settings which I have found to have the highest speed).

I recently noticed while rereading the documentation that fcl supports a fcl::Convex<> primative type. Presumably, this would use a better support function at the narrowphase level, and give a pretty significant speed boost compared to assuming the meshes may be non-convex. However, I cannot seem to find a way to add a convex mesh file into any broadphase collision managers?

Basically, my current code looks something like this:

  using Model = fcl::BVHModel<fcl::OBBRSSd>;

  // Creation of the collision objects:
  for (int i = 0 ; i < number_of_rigid_bodies ; ++i) {
    auto rigid_body = std::make_shared<Model>();
    rigid_body->beginModel();

    for (for const auto& mesh_file : mesh_files) {
      // Load in the object_geometry geometry:
      rigid_body->addSubModel(mesh_file.vertices, mesh_file.triangles);
    }
    rigid_body->endModel();

    // Use the meshes above to create a new collision object
    rigid_bodies[i] = new fcl::CollisionObjectd(rigid_body, Eigen::Matrix4d::Identity());

    // Compute the axis-aligned bounding box of the new object as a whole:
    rigid_bodies.back()->computeAABB();
  }

And I would like to tell fcl to treat the lowest level meshes as convex, so changing this line:

rigid_body->addSubModel(mesh_file.vertices, mesh_file.triangles);

to something like this:

rigid_body->addSubModel(fcl::Convexd(mesh_file.vertices, mesh_file.triangles));

Thanks!

@OxDuke
Copy link

OxDuke commented Oct 13, 2022

With the current implementation of fcl, I don't think you are able to do:

And I would like to tell fcl to treat the lowest level meshes as convex, so changing this line:

The way I would do it is to create a bunch of fcl::CollisionObject<> using fcl::Convex<> as the collision geometry, and add these collision objects into a broadphase collision manager (e.g. fcl::DynamicAABBTreeCollisionManager<>).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants