flexible-collision-library / fcl

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

how to get tow collide objs contacts #590

Open myagen opened 1 year ago

myagen commented 1 year ago

hello my friends I noticed that getting the contact points of two colliding objects was wrong,as bellow is my testing codes

fcl::CollisionResult<S> local_resul;

local_result.clear(); std::vector<Contact<S>> contacts; contacts.clear();

detail::MeshCollisionTraversalNode<BV> node;

   if (!detail::initialize<BV>(
                node, m1, pose1, m2, pose2,
              `  CollisionRequest<S>(num_max_contacts, true, num_max_contacts, true), local_result)) {`
                return -1;
            }
       ` node.enable_statistics = true;`

       ` detail::collide(&node);`
      `  if (local_result.numContacts() > 0) {`
         `   /*local_result.getContacts(contacts);`
        `    std::sort(contacts.begin(), contacts.end());*/`
          `  local_result.clear();`

          `  CollisionRequest<S> request(num_max_contacts, true);`
         `   int num_contacts = collide(&m1, pose1, &m2, pose2, request, local_result);`
        `    local_result.getContacts(contacts);// `

}

local_result.getContacts(contacts); is not right to get the contacts

could you tell us how to get these contact points by use the function getContacts

Thanks!