Programmatically create a multi-body chain

Official Python bindings with a focus on reinforcement learning and robotics.
Post Reply
Posts: 1
Joined: Tue Aug 21, 2018 12:02 pm

Programmatically create a multi-body chain

Post by chhinze » Tue Aug 21, 2018 1:09 pm

I am trying to create a multibody chain in pybullet similar to the C++ example in examples/MultiBody/SerialChains.{cpp|h}. So far the plan is to use

Code: Select all

mID = createMultibody(...)
for this purpose. So far, the following problems occured:
  • spherical joints do not seem to work. As far as I was able to follow the code, the problem lies in class examples/SharedMemory/PhysicsServerCommandProcessor which creates a multibody object with a ProgrammaticUrdfInterface instance. Is there a possibility to bypass the loading of an URDF file on multibody creation to directly create a btMultiBody object? Or would this need a rewriting of the pybullet/C API?
  • even when using rotary joints (to create a 2D representation) I was not able to create the joints between the ends of two links. Instead, the joint was always rotating around the center of mass of the parent link. Is there a way to specify the joint position w.r.t. the parent body, which I missed? I only found the linkPositions parameter specifying the position from joint to child body.
Best regards

Posts: 14
Joined: Tue Sep 18, 2018 7:50 pm

Re: Programmatically create a multi-body chain

Post by richardbloemenkamp » Fri Sep 28, 2018 5:29 pm

Not sure I understand it perfectly but I maybe my example video: can help you. The sourcecode is found at ... Basically I use extra small objects as joint elements. There may be better ways though.

User avatar
Erwin Coumans
Site Admin
Posts: 4183
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA

Re: Programmatically create a multi-body chain

Post by Erwin Coumans » Fri Oct 05, 2018 1:04 am

We didn't expose spherical joints in PyBullet yet, since none of our robots have spherical joints. You can use multiple revolute joints though.

>> Is there a way to specify the joint position w.r.t. the parent body,

Yes. I would suggest first learning a bit more about URDF, that gives a better idea.
The 'linkPositions' and 'linkOrientations' allows to express the link/joint frame. In addition, you can express the inertial frame of each link, and the visual shape/collision shape have their own local frames too.

The UrdfEditor can also help, see ...
(you can load a URDF, then it can programmatically re-create a similar multibody as the URDF)

Post Reply