Angulating a rigidBody not known

Post Reply
jhasketan
Posts: 5
Joined: Sat Sep 14, 2019 7:24 am

Angulating a rigidBody not known

Post by jhasketan »

Hi All,

Can somebody please help me telling how can I angulate a rigidBody using bullet physics in C++. I can translate and rotate using btTransform but I did not see interface to angulate around a joint. Rotation will rotate around the center. That is not what I want. I want to angulate the rigidBody around one end. My rigidBody are kind of stick.

Thanks a lot for the help.
Regards,
Jhasketan
User avatar
drleviathan
Posts: 849
Joined: Tue Sep 30, 2014 6:03 pm
Location: San Francisco

Re: Angulating a rigidBody not known

Post by drleviathan »

It is unclear to me exactly what you want to do so I will describe two solutions:

(1) If you want a btRigidBody to "tumble" about some point at its end then you would set its center of mass (COM) at that point. The COM is the <0,0,0> point in the btCollisionShape's local frame, and it is the "translation" of the btRigidBody in the world-frame.

So you would need to use a btCollisionShape for your stick whose local origin is at its end. One way to do this would be to use a btConvexHullShape whose points are shifted such that the end of the stick is at the origin. If you're using some other btConvexShape (such as a btBoxShape which implicitly puts the local origin at the center of the box) then you would need to wrap that shape in a btCompoundShape and offset the sub-shape with an appropriate child transform.

(2) If you want a normal uniform stick with its COM at its center but you want to "pin" the end of the stick so that it swivels there, then you wouldn't need to shift the COM as in (1) but instead use a constraint (like a btPoint2PointConstraint, but maybe you want btHingeConstraint to limit rotation about a specific axis) to lock the local-frame point of the stick to a world-frame point.
jhasketan
Posts: 5
Joined: Sat Sep 14, 2019 7:24 am

Re: Angulating a rigidBody not known

Post by jhasketan »

Thanks a lot drleviathan for your reply. I could solve the rotation issue but I have new issue now.
I have connected stick1 to stick2 (both are btRigidBody) using hinge constraint. Also stick1 is connected to a static body(zero mass) using hinge constraint. Now I want to move tip of the stick2 to an arbitrary point and check if it is possible or not.

Can you please give some pointer how to move tip of the stick2(rigidBody) to a specified point ?

Thanks a lot for your help.
User avatar
drleviathan
Posts: 849
Joined: Tue Sep 30, 2014 6:03 pm
Location: San Francisco

Re: Angulating a rigidBody not known

Post by drleviathan »

What you're asking about is called "inverse kinematics". You know the final destination and the problem is to determine the path to get there, or whether a valid path exists or not. I don't have the time or expertise to write up tutorial here. I recommend you research the subject to see what info you can find. Also, you should know Bullet has an InverseKinematic library so it may have an API to help you achieve what you want, however I've never used it.
Post Reply