btRigidBody: center of mass transform vs. world transform

User avatar
ejtttje
Posts: 96
Joined: Mon Nov 03, 2008 9:57 pm

btRigidBody: center of mass transform vs. world transform

Post by ejtttje »

I was initially under the impression that the rigid bodies handled having a center of mass at an offset from the rigid body's location, due to functions such as setCenterOfMassTransform vs. the inherited setWorldTransform. (This would be handy for robotics, where we define the origin of a link at the joint, not at the center of mass...)

However, after some debugging, setCenterOfMassTransform seems to be directly setting the world transform instead of a separate offset. Some documentation here would be helpful... thanks!

EDIT: and by "documentation", I'm thinking of the doxygen page, which is kind of barren for btRigidBody:
http://www.continuousphysics.com/Bullet ... dBody.html
pico
Posts: 229
Joined: Sun Sep 30, 2007 7:58 am

Re: btRigidBody: center of mass transform vs. world transform

Post by pico »

Hi,

you can use a compound shape to set an own center of mass. One of the bullet demos shows how todo this.

Maybe you also want to check out this thread (scroll down to the end):
http://www.bulletphysics.com/Bullet/php ... er+of+mass
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA

Re: btRigidBody: center of mass transform vs. world transform

Post by Erwin Coumans »

I agree, it can be misleading. For a Bullet btRigidBody, the world transform == center of mass. If you need to shift the center of mass, you need to use a btCompoundShape, and shift the collision shape relative to the local rigid body origin. The reason for both names, is that the collision detection can be used independently (btCollisionWorld), and for collision detection "center of mass" has no meaning.

This should be made more clear in the Wiki and Bullet manual and doxygen/source code.
I'll make some updates for upcoming Bullet 2.73 manual.

Thanks,
Erwin

By the way, there is an IRC discussion channel #bulletphysics at freenode.net
User avatar
ejtttje
Posts: 96
Joined: Mon Nov 03, 2008 9:57 pm

Re: btRigidBody: center of mass transform vs. world transform

Post by ejtttje »

Thanks. I guess btCompoundShape is the way to go to offset the collision shape from the center of mass. Given that the rigid body is defined to be at the CoM, I'm afraid I'm still not quite clear on why there is separate functions for world transform vs. CoM transform, but maybe the new documentation will explain that more... it looks like setCenterOfMassTransform does some extra "stuff", but I don't quite follow it.

Should I always use setCenterOfMassTransform on my rigid bodies then, and avoid setWorldTransform()?

PS I'm on chat.us.freenode.net #bulletphysics... there's some people in the channel, but seems everyone is AFK.