Someone familiar with btMultiBody please let me know if this is correct.

Post Reply
stephenop
Posts: 4
Joined: Mon Apr 30, 2018 3:36 pm

Someone familiar with btMultiBody please let me know if this is correct.

Post by stephenop »

Before my questions I have a little reference diagram attached that I'll reference.

The purple frame is the world coordinate system.
The red frame is the center of mass and principle axis orientation.
The black frame is a revolute joint location, the axis is along the z in this image.
The gold frame is the axis I currently have set for the origins of the visual bodies which I have displayed in opengl and a custom engine.
This image is a stand-in for an extremely detailed robot model.

Since I am trying to get as accurate physics as bullet will get me, I want to make sure I am feeding the inertia, and frame relationships in correctly. Here I will step through what I think needs to be done and please correct where things are messed up. I've worked with ODE and several in house dynamics engines over the years and excited to use bullet for this project since featherstone is now used.

Assume that I have inertial frames initially aligned to world coordinates, then I would need to diagonalize to get the principle axis.
i.e.,
inertia.diagonalize(&rotation);
btMultiBody(1, mass link 1, inertia link 1 diagonalized, ...)
btMultiBody->setBasePos(vector to com 1);
Do I need to set the a rotation from world to base com to account for diagonlization?
btMultiBody->setWordlToBaseRot(rotation);

----Okay so assuming that setup the base correctly I now add the next link via a revolute joint. This is where things get really unclear to me. I can't tell which things need to be with respect to which coordinate frames.

rotParentToThis: Is this the rotation which aligns the COM frame of parent with the joint frame? Since in my example the joint frame is aligned with world frame this rotation would be the rotation found in step 1 for diagonalizing the inertia correct?

jointAxis: I am assuming this axis of rotation is in the joints frame?

parentComToThisPivotOffset: The translation from parent COM to joint frame. The comment says in parent frame. Let's assume I have this translation pre-diagonalization, i.e., in the world frame. I'm assuming then I need to rotate this translation by the same transform as the parent frame.

thisPivotToThisComOffset: Vector from joint frame to link 2 COM.

91 void setupRevolute(int linkIndex, // 0 to num_links-1
92 btScalar mass,
93 const btVector3 &inertia,
94 int parentIndex,
95 const btQuaternion &rotParentToThis, // rotate points in parent frame to this frame, when q = 0
96 const btVector3 &jointAxis, // in my frame
97 const btVector3 &parentComToThisPivotOffset, // vector from parent COM to joint axis, in PARENT frame
98 const btVector3 &thisPivotToThisComOffset, // vector from joint axis to my COM, in MY frame
99 bool disableParentCollision=false);

Thank you so much for clarifying! I believe this little example is general enough that if cleared up should well explain the basics of btmultibody.

PS: The "documentation" which consists of the multibody demo and urdf importer are a bit murky. The bullet code seems to lack comments almost entirely o_O? Also, the names are often ambiguous so I want to make sure I"m setting this up correctly. I'm not familiar with bullet history but surprising to see such a large library hurting for comments so badly. Too much to do, too little contributors?
Attachments
example 2 body system.PNG
example 2 body system.PNG (16.51 KiB) Viewed 4745 times
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA
Contact:

Re: Someone familiar with btMultiBody please let me know if this is correct.

Post by Erwin Coumans »

I strongly recommend first using the PyBullet Python bindings, and loading URDF or SDF files, it is documented in the https://docs.google.com/document/d/10sX ... e70wns7io3.
Our recent RSS paper (Sim-to-Real: Learning Agile Locomotion For Quadruped Robots) is also using PyBullet for real robots, see link.

Once you get your robot working fine, you could drop Python and go straight into C++. There is also a robotics-oriented C++ API that is very similar to the PyBullet Python API, the header file is here.

Also, you can learn from the URDF conversion https://github.com/bulletphysics/bullet ... t.cpp#L365 to see how maximal coordinates and reduced coordinates compare, and how the btMultiBody API works.

I think the naming of classes and methods in Bullet makes a lot of sense. If you really want to go into the btMultiBody implementation details (it was implemented by a several people), it is best to become familiar with the theory. In particular Brian https://people.eecs.berkeley.edu/~jfc/m ... Thesis.pdf and https://www.researchgate.net/publicatio ... vironments.

Good luck!
DaoiYjdVAAA4olg.jpg
DaoiYjdVAAA4olg.jpg (110.63 KiB) Viewed 4687 times
stephenop
Posts: 4
Joined: Mon Apr 30, 2018 3:36 pm

Re: Someone familiar with btMultiBody please let me know if this is correct.

Post by stephenop »

Thanks!

I read Brian's thesis years ago which is why I was looking to use Bullet for this project. I'm fully aware of the underlying theory. I've implemented featherstone's ID/FD algorithms twice at this point for proprietary systems because the opensource solutions back then were not flexible, sufficient, had errors, or who I was working for wanted in house solutions, i.e., no open source.

I've been using the URDF/SDF Importer example and multibodydemo to back out the basics of setting up the simulation.

The issue is lack of implementation and API documentation.

I did initially just use the URDF importer example but upon inspection found many errors in the simulation, see the comment on diagonilization as a starter. Which led me to dig in, but then found zero comments or information on setting up the system for btmultibody.

There is basically no good general documentation on setting up your robot in bullet besides "just load the URDF."

Rather than another interface I'm just learning bullet's API (which is what a lot of developers will need to do).

Anyway, this is all belated, I'm at about 80% setup at this point with custom opengl render, working urdf importer etc. Once I'm finished I'll put some tutorials out or something so if I can get any questions answered as I go that will greatly speed up the process and hopefully be helpful to the bullet community and new users.

I agree, the names in general are fine and I would not change them. However, functions like setupRevolute need more presentation. At first it was not apparent what vectors and things were needed.

void setupRevolute (int linkIndex, btScalar mass, const btVector3 &inertia, int parentIndex, const btQuaternion &rotParentToThis, const btVector3 &jointAxis, const btVector3 &parentComToThisPivotOffset, const btVector3 &thisPivotToThisComOffset, bool disableParentCollision=false)

A single diagram would make this clear in an instant. I had to dig around in the URDF Importer and Multibodydemo to make sure that I was including the correct transforms.

Anyway, the last thing that's bogging things up is collider, btmultibody, and my visual representation. Essentially making sure that the collision shape is in correct place/orientation, btmultibody has correct link/joint relationships in terms of orientation and position, and that visual representation is correct.

Best regards!
elvis
Posts: 3
Joined: Tue Aug 21, 2018 5:29 am

Re: Someone familiar with btMultiBody please let me know if this is correct.

Post by elvis »

Hi Stephenop,

did you succeed to create a robot using btMultiBody? I liked when I saw a picture to exact what I want to do.

I have a really similar case. I have a robot (with mesh and kinematics defined in a 3D CAD/CAM software) and I want to simulate interactions with it.
I need to design the robot somehow in Bullet, add it to the dynamics world and when its joints are changing the position in Bullet, to update the joints in my application.

Do you think that is possible to share some results or some idea about this?

What I have tried:
- I exported my Robot as URDF - and imported in Bullet Physics. Everything OK. But the importer is really linked to Bullet Open GL UI. I cannot include the importer in my application. Probably I will need to change the code a lot. Well actually I want to use Bullet only for computations, I don't care about visualizing the object. I am visualizing the robot in my application.
- I tried to create the robot with rigid bodies and hinge constraints. But the robot is balancing, the joints are continuously moving due to gravitation.

Thank you a lot!
Post Reply