Different collision results between pybullet and C++ API

Post Reply
wbthomason
Posts: 9
Joined: Fri May 10, 2019 8:18 pm

Different collision results between pybullet and C++ API

Post by wbthomason »

I'm currently trying to use the Bullet C++ API for collision detection. I load a robot description from URDF (not using Bullet's URDF importer, though this could change), construct btCollisionShapes for all of the link collision geometries, and add them as btCollisionObjects to a btCollisionWorld. When I need to test for collisions, I update the world transforms of each collision object, run performDiscreteCollisionDetection, and look at the manifolds and contact points.

I currently get a large number of self-collisions with my model, which could just mean that I need to use better convex geometries/similar (the model looks correct in the debug drawer, so I think the link objects are being correctly loaded).

However, when I load the same model in pybullet with loadUrdf, it reports zero contact points (after running performCollisionDetection, so the contact manifolds ought to be up to date).

I've tried going through the URDF parsing example to see if I'm missing anything, and (though I can't be certain), it seems like the only steps from that example that I don't take are those relating to dynamics.

I'm at a bit of a loss for how to fix/debug this. Should I be loading my robot differently, e.g. creating a btMultiBody? Does the URDF loader in pybullet do anything that would change which collisions are kept (e.g. a filter of some sort, which I looked for but couldn't find in the example)? Are there other things I should look at?

I've attached the model (just the PR2 model from ROS's pr2_description with a few joints I don't care about changed to be fixed) in case that's helpful. It does not include the meshes, as this put the attachment over the maximum filesize, but these are unmodified from the pr2_description package. Thank you!
Attachments
pr2_model.tar.gz
(17.16 KiB) Downloaded 177 times
wbthomason
Posts: 9
Joined: Fri May 10, 2019 8:18 pm

Re: Different collision results between pybullet and C++ API

Post by wbthomason »

Some additional information: this model has neither the "group" nor "mask" attributes for any of its collisions, so I don't think that could be the cause (Bullet's UrdfParser handles these attributes; my URDF loading does not).
wbthomason
Posts: 9
Joined: Fri May 10, 2019 8:18 pm

Re: Different collision results between pybullet and C++ API

Post by wbthomason »

I believe this is solved - it turns out that I was paying too much attention to the C++, and not enough to pybullet. From the pybullet docs:
URDF_USE_SELF_COLLISION: by default, Bullet disables self-collision.
Enabling self-collision gets me the expected collision set.
Post Reply