2.74 btHingeConstraint "angular only" not used

Post Reply
arcwf
Posts: 7
Joined: Fri Mar 20, 2009 3:26 am

2.74 btHingeConstraint "angular only" not used

Post by arcwf »

btHingeConstraint does not use the m_angularOnly flag (enabled by setAngularOnly(...)) in its new solver implementation, which is the default. It will only take effect if you use the obsolete solver implementation, which can be enabled with the following client code:

Code: Select all

#define IN_PARALLELL_SOLVER // !!! grants public access to btHingeConstraint data members
#include <BulletDynamics/ConstraintSolver/btHingeConstraint.h>
. . .
btHingeConstraint * hinge = new btHingeConstraint( . . . )
hinge->setAngularOnly( true );
hinge->m_useSolveConstraintObsolete = true; // !!! normally a private data member
. . .
I am using a btHingeConstraint to achieve an "upright" constraint that has been discussed elsewhere in the forum. I had to make this fix after upgrading from 2.73 to 2.74 in order to get double-precision (BT_USE_DOUBLE_PRECISION) working successfully on Gentoo GNU/Linux for amd64.

I have recently replaced our own physics engine with Bullet, and am very pleased with the results. The code is well designed and easy to follow. The overall object design and C++ coding style is actually very close to ours, which made the integration surprisingly easy. The lead game designer got even more excited when she saw everything in our world bouncing around!

Great work guys :D
--Christopher
arcwf
Posts: 7
Joined: Fri Mar 20, 2009 3:26 am

Re: 2.74 btHingeConstraint "angular only" not used

Post by arcwf »

FYI, this solution no longer works in Bullet 2.76; the constraint just doesn't take effect--I don't know why yet.

If anyone has solved the "upright" problem effectively, please post your solution. Nothing that I have yet tried with hinge or 6dof constraints, or the custom UprightConstraint code (which no longer compiles successfully) has yet to work. :(

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

Re: 2.74 btHingeConstraint "angular only" not used

Post by Erwin Coumans »

arcwf wrote:FYI, this solution no longer works in Bullet 2.76; the constraint just doesn't take effect--I don't know why yet.

If anyone has solved the "upright" problem effectively, please post your solution. Nothing that I have yet tried with hinge or 6dof constraints, or the custom UprightConstraint code (which no longer compiles successfully) has yet to work. :(

Thanks
-- Christopher
We removed the obsolete code of the btHingeConstraint, not realizing that the 'angular factor' was not implemented in the new code. We'll look into fixing this.

In the meanwhile: have you tried using the angular factor, that can force objects to stay up (only allow rotation along a given world-space axis), for example if gravity is the Y axis:

Code: Select all

btVector3 angFac(0,1,0);
body->setAngluarFactor(angFac);
Thanks,
Erwin
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA
Contact:

Re: 2.74 btHingeConstraint "angular only" not used

Post by Erwin Coumans »

Latest trunk should add support for angularOnly hinges: see http://bit.ly/cH8Kqy

Can you try if this works for you?
Thanks,
Erwin
arcwf
Posts: 7
Joined: Fri Mar 20, 2009 3:26 am

Re: 2.74 btHingeConstraint "angular only" not used

Post by arcwf »

Thanks Erwin.

I have just built the latest Bullet SVN trunk. Unfortunately, using the non-obsolete solver in this version with hinge->setAngularOnly(true) also constrains translation rather than just affecting "angular only", i.e. the body will rotate as desired but not move. However, our code that sets up the hinge is the same as it was for Bullet 2.74, so it is possible that we need to code the setup differently to get it working properly.

On the other hand, while your were making the change for btHingeConstraint::setAngularOnly(...), I did solve the "upright" problem using the btGeneric6DofConstraint instead, and it works perfectly! That solution is described in post http://www.bulletphysics.org/Bullet/php ... 494#p19494

Your suggestion to use btRigidBody::setAngularFactor(...) also works and is clearly the simplest solution of all. Nevertheless, the btGeneric6DofConstraint solution is the best for us because our worlds are spherical planets, so the "upright" axis changes as bodies move rather than being fixed to the universal Y axis.

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

Re: 2.74 btHingeConstraint "angular only" not used

Post by Erwin Coumans »

Unfortunately, using the non-obsolete solver in this version with hinge->setAngularOnly(true) also constrains translation rather than just affecting "angular only", i.e. the body will rotate as desired but not move.
That was not intended, we'll test and fix this asap.

Good you found another solution, thanks for the feedback!
Erwin
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA
Contact:

Re: 2.74 btHingeConstraint "angular only" not used

Post by Erwin Coumans »

"angular only" is now fixed and tested in latest trunk: http://code.google.com/p/bullet/source/detail?r=2154

The hinge also has a local axis, so it should work for spherical worlds/gravity. Anyhow, if the btGeneric6DofConstraint works for you, you might just stick with that.
Thanks for the feedback,
Erwin
henokyen
Posts: 6
Joined: Wed Feb 20, 2013 6:14 am

Re: 2.74 btHingeConstraint "angular only" not used

Post by henokyen »

Hi all,
I am new to physics simulation
and I am trying to create a joint between two legs fro my robot.
for that i am using the hinge constraint. but can get it yet, can anyone post me a code for doing it /
Thank you
Post Reply