btConeTwistConstraint with _swingSpan1 != _swingSpan2

norbie
Posts: 21
Joined: Mon Feb 11, 2013 1:57 pm

btConeTwistConstraint with _swingSpan1 != _swingSpan2

Post by norbie »

Hi,

I was wondering how a btConeTwistConstraint should behave when first two parameters of its setLimit function (_swingSpan1, _swingSpan2) are different, and also a _twistSpan is set, e.g. something like this:

Code: Select all

 		btConeTwistConstraint *joint1 = new btConeTwistConstraint( *capsuleBody1, *capsuleBody2, localA, localB );
 		joint1->setLimit( DEGREETORAD( 30 ), DEGREETORAD( 60 ), DEGREETORAD( 90 ) );
capsuleBody1-2 are two capsule shaped btRigidBody-s. (The second body is actually rotated -90 degrees on the Z-axis, so one can consider the first body being the spine and the second being the arm of a ragdoll.)
localA is the transformation of the constraint in the local space of the first body, abd localB is the transform of the constraint in the local space of the second body, so when the whole system is imagined in "world space" they give the same position and orientation.

I expected the second body to be able to move inside a fixed cone defined by _swingSpan1 and _swingSpan2 independent from the actual twist value!
Instead it seems that the axes of _swingSpan1 and _swingSpan2 are rotated by the twist rotation.

Is it OK this way?

It also seems strange because if I only allow one of the two swing limits and set the other to 0, that one swing axis is not rotated by the twist rotation.

Any idea how it should work?
norbie
Posts: 21
Joined: Mon Feb 11, 2013 1:57 pm

Re: btConeTwistConstraint with _swingSpan1 != _swingSpan2

Post by norbie »

The problem is solved since then. The rigidbody parameters of btConeTwistConstraint ctor were mixed up (here the order of the rigid bodies counts). The correct ctor call is:

Code: Select all

		btConeTwistConstraint *joint1 = new btConeTwistConstraint( *capsuleBody2, *capsuleBody1, localB, localA );
so if in a kinematic chain the child should be given first and then the parent.