generic 6DOF constraint in pyBullet

Official Python bindings with a focus on reinforcement learning and robotics.
Post Reply
jochemspek
Posts: 7
Joined: Thu Feb 01, 2018 3:00 pm

generic 6DOF constraint in pyBullet

Post by jochemspek »

Hi, I'm looking for a way to create (or emulate) a btGeneric6DofConstraint with user constraints in pybullet but i'm struggling to see how to do this. I thought I was brave by trying to add a generic constraint type in pyBullet, but that's too deep a rabbithole for me. The reason I need the btGeneric6DofConstraint is that I'm analysing the DOFs of two objects relative to eachother and then create a constraint that encapsulates those DOFs without having to do collision detection/simulation. I know I could use the btGeneric6DofConstraint in C(++) context or use the blender python interface, but is it possible to use pyBullet for this directly?

thanks,

Jochem van der Spek
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA
Contact:

Re: generic 6DOF constraint in pyBullet

Post by Erwin Coumans »

PyBullet doesn't use constraints by default, it uses btMultiBody primarily. So joints are not represented by constraints internally.

Code: Select all

then create a constraint that encapsulates those DOFs without having to do collision detection/simulation
Why? Can you explain more in detail what you try to do with PyBullet on a higher level?

There is a UrdfEditor, that let's you build more complex constructions in Python and then instantiate it in PyBullet.
jochemspek
Posts: 7
Joined: Thu Feb 01, 2018 3:00 pm

Re: generic 6DOF constraint in pyBullet

Post by jochemspek »

My goal is to create accurate and fast drop simulations of arbitrary mechanically complex assemblies of rigid objects like this bracelet consisting of 43 interlocking parts. https://postimg.cc/Jsxd0M1j)

In order to do proper physical simulation I had to split the shells or segments of the model(s) into combinations of convex shapes which I did using VHACD (see my previous post at viewtopic.php?f=9&t=12009&p=40395#p40395). Unfortunately for more complex objects like the bracelet, this is not sufficient and because of the cyclic nature of the physical relations (triplets of segments connected to each other via mechanical connection) the simulation suffers from instabilities and becomes prohibitively slow.

Simulating single pairs of mechanically connected segments works fine however, even in realtime. Hence the idea arose to simulate all the pairs in the assembly and then analyse the DOF between each pair and encode this in a generic6DOF constraint. Finding the basis frame for the constraint works quite well for the bracelet: https://giphy.com/gifs/xj1cCQzz7MiW6OFXsI -you see two reference frames, one fixed representing the original position and orientation, the other representing the iteratively calculated pivot point between the segments.

The next step is to do the simulation of the entire assembly using just constraints without collision between the mechanically connected pairs, and using collision of convex hulls between non-connected pairs. This should be much much faster.

I noticed however that the btGeneric6DOFConstraint is unfortunately not exposed in pybullet, hence my question. I know I could do the entire project in C++ and have access to the btGeneric6DOF, but this does not fit our production pipeline very well which is entirely python based. I am now thinking to use the Blender python module, as this does seem to expose btGeneric6DOF and can run (and render) the simulation. However, if there is another way (by generating Urdf files perhaps?) I would love to hear that!
Post Reply