btGeneric6DofConstraint 'explodes' by locking axes

oleg
Posts: 2
Joined: Wed Feb 24, 2010 3:34 pm

btGeneric6DofConstraint 'explodes' by locking axes

Post by oleg »

I'm trying to lock rotation about X- and Z-axis, so only rotation about the Y-axis should be allowed.
Locking all other axes works fine, but if I lock these two axes, btGeneric6DofConstraint becomes unstable.
To reproduce this effect you can exchange 4 lines of code after creation of the first slider in the "Constraint Demo" (ConstraintDemo.cpp)
with the following lines:

Code: Select all

// unlock linear limit
spSlider6Dof->setLinearLowerLimit( btVector3(1,1,1) );
spSlider6Dof->setLinearUpperLimit( btVector3(-1,-1,-1) );

// lock X and Z axes
spSlider6Dof->setAngularLowerLimit( btVector3(0,1,0) );
spSlider6Dof->setAngularUpperLimit( btVector3(0,-1,0) );
As I have said, it only 'explodes' if I unlock the Y-axis. For all the other ones, it seems to be fine.
Is there maybe any other way to lock rotational axes?
User avatar
rponomarev
Posts: 56
Joined: Sat Mar 08, 2008 12:37 am

Re: btGeneric6DofConstraint 'explodes' by locking axes

Post by rponomarev »

Hello,

The btGeneric6DofConstraint uses Euler angles, so rotation around Y-axis should be in (-PI/2, PI/2) interval.
When Y-rotation becomes close to PI/2 (or -PI/2) X- and Z- Euler rotations become undefined

To avoid this situation you may rotate frames at constraint creation time by PI/2 around X and unlock Z axis instead of Y, like this:

Code: Select all

frameInA.getBasis().setEulerZYX(PI/2,0,0);
frameInB.getBasis().setEulerZYX(PI/2,0,0);
Hope this will help,
Roman
oleg
Posts: 2
Joined: Wed Feb 24, 2010 3:34 pm

Re: btGeneric6DofConstraint 'explodes' by locking axes

Post by oleg »

OK,
I thought only limits of singularities (-PI..PI) could 'explode' the constraint, as it is described in the constraint demo.
But using Euler angles explains the occurrence of this problem.
Everything is clear now!

Thanks a lot for your help!
Oleg