bulletphysics / bullet3

Bullet Physics SDK: real-time collision detection and multi-physics simulation for VR, games, visual effects, robotics, machine learning etc.
http://bulletphysics.org
Other
12.72k stars 2.88k forks source link

collision detection: btConeShape behaves like cylinder shape. #1375

Closed eastskykang closed 7 years ago

eastskykang commented 7 years ago

I am using bullet collision for collision detection.

As I define cone object as follows:

btCollisionShape coneCollisionShape = new btConeShapeZ(radius, height); btCollisionObject coneCollisionObject = new btCollisionObject(); coneCollisionObject->setCollisionShape(coneCollisionShape);

object occupies cylindrical space, not cone shape. Am I missing something here?

erwincoumans commented 7 years ago

The RollingFrictionDemo uses cone shapes and they work fine. https://github.com/bulletphysics/bullet3/blob/master/examples/RollingFrictionDemo/RollingFrictionDemo.cpp Can you create a btRigidBody instead of btCollisionObject?

erwincoumans commented 7 years ago

How do you determine what space is occupied?

eastskykang commented 7 years ago

Thank you so much for your response.

As I put an unit sphere to certain position (which is not supposed to be occupied), collision was detected. (and for sphere, cylinder or box, it never happened.) I also tried to use btConeShape or btConeShapeY but it seems they also fully occupy the cylindrical space.

By the way, I only want to use collision detection feature, since I have my own dynamics engine. Is using btRigidBody proper way to do it?

erwincoumans commented 7 years ago

Why using your own dynamics engine, since it obviously works well with btRigidBody, LOL?

Now seriously, it should work just fine using btCollisionObject as well. How do you perform the query? You should be able to create a minimal self-contained program to perform the check, in less than 100 lines (only using Bullet libraries). If so, please share the test program that compiles with a recent compiler on either Linux, Mac OSX or Linux.

Do you set the world transforms for the query properly? What is the contact point information (closest distance, contact normal etc)? Note that a positive distance means no collision.

In addition, you may also experiment a bit with pybullet, there is a lot of interesting stuff in there to experiment with, including collision detection between shapes. Ah, I just realize that cones are not exposed in that API, I can add it easily and it lets you do some tests/comparisons/queries.

eastskykang commented 7 years ago

@erwincoumans Thank you for comment. I am actually building a dynamics simulator for robotics (for some special purposes). That's why I am using bullet for just for collision detection.

And I realized I was detecting collision by using collision between manifolds. As I changed my implementation it seems works fine.

Anyway, thank you so much for your quick and kind response. I will close the issue.

erwincoumans commented 7 years ago

Robotics is the main focus of Bullet nowadays, please check http://pybullet.org There is URDF and SDF loading, Inverse Dynamics, Inverse Kinematics, motor control etc. We simulate KUKA arm grasping, quadruped/biped robot locomotion etc.

erwincoumans commented 7 years ago

See some new paper using pybullet:https://stanfordvl.github.io/ntp/?utm_content=buffer8b1fc Also our researchers at Google Brain and X use this simulator in both C++ and Python.

eastskykang commented 7 years ago

@erwincoumans Great! thank you so much for your suggestion. I will take a look and consider use bullet dynamics engines.