Constraining all 6 Degrees of Freedom

daBrado
Posts: 11
Joined: Thu Oct 05, 2006 10:41 am

Constraining all 6 Degrees of Freedom

Post by daBrado »

Hi,

I'm new to Bullet and physics engine in general, so I hope you all can forgive a possibly naive question.

I want to be able to make objects grabable using the ray cast from an input device that has 6 DoF. Namely, if I point the device at the object and "grab" it, it is as if a solid bar is connected between the input device and the object. So, until its release, the object would follow all translations and rotations of the input device, as if one was holding the end of the bar and swinging it around.

Could / should this be done using the btGeneric6DofConstraint ?

Thanks for any help,
Braden
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA

Re: Constraining all 6 Degrees of Freedom

Post by Erwin Coumans »

daBrado wrote:Hi,

I'm new to Bullet and physics engine in general, so I hope you all can forgive a possibly naive question.

I want to be able to make objects grabable using the ray cast from an input device that has 6 DoF. Namely, if I point the device at the object and "grab" it, it is as if a solid bar is connected between the input device and the object. So, until its release, the object would follow all translations and rotations of the input device, as if one was holding the end of the bar and swinging it around.

Could / should this be done using the btGeneric6DofConstraint ?

Thanks for any help,
Braden
Indeed, you can use the btGeneric6DofConstraint. In fact, by default all degrees of freedom are locked, so no need to configure the limits. Just choose an appropriate local coordinate frame for the attachment.

See the ColladaDemo for an example implementation:

Code: Select all

btGeneric6DofConstraint* genericConstraint = new btGeneric6DofConstraint(
							*bodyRef,*bodyOther,
							localAttachmentFrameRef,localAttachmentOther);

				m_demoApp->getDynamicsWorld()->addConstraint( genericConstraint );
This btGeneric6DofConstraint follows the COLLADA Physics specification, although not all features are implemented yet. Right now, each DOF can either be fully locked, or fully free, no limits or motors yet. Also bear in mind that there has been some refactoring to cleanup the classes, so expect a few released with (hopefully) minor bugfixes.

Please let me know if there are any issues.
Thanks,
Erwin
daBrado
Posts: 11
Joined: Thu Oct 05, 2006 10:41 am

Re: Constraining all 6 Degrees of Freedom

Post by daBrado »

Erwin Coumans wrote:Indeed, you can use the btGeneric6DofConstraint. In fact, by default all degrees of freedom are locked, so no need to configure the limits. Just choose an appropriate local coordinate frame for the attachment.
So, using btGeneric6DofConstraint, would I create a dummy btRigidBody that represents the input device, and then change its m_worldTransform to track the input device's location and orientation?

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

Re: Constraining all 6 Degrees of Freedom

Post by Erwin Coumans »

daBrado wrote:
Erwin Coumans wrote:Indeed, you can use the btGeneric6DofConstraint. In fact, by default all degrees of freedom are locked, so no need to configure the limits. Just choose an appropriate local coordinate frame for the attachment.
So, using btGeneric6DofConstraint, would I create a dummy btRigidBody that represents the input device, and then change its m_worldTransform to track the input device's location and orientation?

Thanks,
Braden
Yes, you create a fixed rigidbody, setup the constraint and move that fixed body.

Note that Bullet is undergoing refactoring, and although the largest changes are over, the API and internals are still changing.
Creating a fixed rigidbody in Bullet 2.14 will look like:

Code: Select all

float mass = 0.f; //means fixed
btCollisionShape* collisionShape = 0;
btRigidBody fixed(mass, btTransform::getIdentity(),collisionShape);
Thanks,
Erwin