BerkeleyAutomation / python-fcl

Python binding of FCL library
BSD 3-Clause "New" or "Revised" License
199 stars 58 forks source link

Why the collision result remain the same, no matter how I change the box scale and position when I run the example.py file #25

Open MarkusZh opened 3 years ago

MarkusZh commented 3 years ago

Why is the collision result always True? And why is the distance between the two objects always -1.0. Actually I have changed the sizes and postions of the test objects for multiple times, sometimes, it is obviouly that the two objects will no collide with each other(for example, I set the two objects very far from each other), but the result remain the unchanged of being Collided. No error was raised. And my python-fcl version is python-fcl-win32-nr. What is wrong with my scripts? or Is there any dependency which I need to install? Thanks a lot for help. image

ebianchi commented 2 months ago

I noticed the same issue, for both the collision checking and distance checking examples. The issue goes away if you re-define the res result object before calling fcl.collide or fcl.distance, e.g.:

req = fcl.CollisionRequest(enable_contact=True)
res = fcl.CollisionResult()
n_contacts = fcl.collide(
    fcl.CollisionObject(box, fcl.Transform()),
    fcl.CollisionObject(cone, fcl.Transform()),
    req,
    res,
)
print_collision_result("Box", "Cone", res)

res = fcl.CollisionResult()   # Add this line to reset the result.
n_contacts = fcl.collide(
    fcl.CollisionObject(box, fcl.Transform()),
    fcl.CollisionObject(cyl, fcl.Transform(np.array([6.0, 0.0, 0.0]))),
    req,
    res,
)
print_collision_result("Box", "Cylinder", res)