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

Wrong Collision Result between complicated mesh and sphere #440

Open
chenyanzz opened this issue Jun 25, 2023 · 5 comments
Open

Wrong Collision Result between complicated mesh and sphere #440

chenyanzz opened this issue Jun 25, 2023 · 5 comments
Assignees

Comments

@chenyanzz
Copy link

chenyanzz commented Jun 25, 2023

Version

  • OS: macos 13.4.1
  • conda_env: python 3.10
  • pip_package: hppfcl==2.2.0

Bug Description

Collision Object 1 is the mesh "model.stl" inside the zip

Collision Object 2 is a Sphere center at (-2, 3, 0), with a radius of 50

Actually the two models DOES have a small slice of space between them,

However, the collide(obj1, obj2) returns a wrong answer:result.isCollision() == True.

And it shows the collision point is (-30.44375973, -43.73033919, 1.37608287)

(It is hard to show that there isn't a collision in a non-convex model in one image, so you can test it in your methods)

I draw the situation on blender:

image

The yellow dot is the collision point hpp-fcl decleared to be. But it is outside the Sphere.

And, However, There is NOT a collison at all.

The blender project is "test.blend" in zip

Testing Env

"test.py" also in the zip file

import hppfcl
import numpy

mesh_stl_path = '/in_zip_file/model.stl'
ball_pos = (-2, 3, 0)
ball_d = 100

# create objects
mesh_model = hppfcl.MeshLoader(hppfcl.BV_OBB).load(mesh_stl_path)
ball_model = hppfcl.Sphere(ball_d / 2)
mesh_obj = hppfcl.CollisionObject(mesh_model)
ball_obj = hppfcl.CollisionObject(ball_model)
place = hppfcl.Transform3f(numpy.array(ball_pos))
ball_obj.setTransform(place)

# try collide
req = hppfcl.CollisionRequest()
result = hppfcl.CollisionResult()
req.enable_contact = True
req.num_max_contacts = 1
hppfcl.collide(mesh_obj, ball_obj, req, result)

print('isCollision:', result.isCollision())
if result.isCollision():
    contacts = result.getContacts()
    contacts = list(map(lambda c: c.pos, contacts))
    print('contacts:', contacts)

Qs

  • Is there some mistake for me ?
  • Is there any approach to quick-fix such situation ?
  • Is it the problem within 'BVHModel' or 'gjk collide test' ?

Attachment ( zip file of everything )

hppfcl-bugreport.zip

@jcarpent
Copy link
Member

At first glance, it might be a problem of normal orientation in the case of BVHs.
This issue would need time to be deeply investigated. Unfortunately, we are lacking of man power to handle this issue rapidly.

@lmontaut
Copy link
Contributor

Hi @chenyanzz,
There doesn't seem to be a mistake from your side. I may have identified the issue but I need more time to debug it.
It has to do with a specialized function which BVH-sphere collisions call.
In the mean time, a quick fix is to replace Sphere by Ellipsoid in your code, like so:

# ball_model = hppfcl.Sphere(ball_d / 2)
ball_model = hppfcl.Ellipsoid((ball_d / 2) * numpy.ones(3))

@chenyanzz
Copy link
Author

@lmontaut
Well, By Using Ellipsoid, the contact point comes to the ball at [ 33.32329434, -26.13812054, -19.20840025], but still results in 'collided' (/cry)

@lmontaut
Copy link
Contributor

Hi @chenyanzz, apologies for the late reply.
I can't seem to reproduce your bug using an ellipsoid instead of a ball.
If I run your code on my side but replace the ball by an ellipsoid:

# ball_model = hppfcl.Sphere(ball_d / 2)
ball_model = hppfcl.Ellipsoid((ball_d / 2) * numpy.ones(3))

I get the following output:

isCollision: False

I am also on macos 13.4.1. I ran your code using the latest hppfcl v. 2.3.5 installed using conda.

I will have a look to fix the bug for the ball case.

@jcarpent
Copy link
Member

@lmontaut Any news on this issue?

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

3 participants