D6 Constraint Limits

luke.titley
Posts: 15
Joined: Fri Sep 08, 2006 3:39 pm

D6 Constraint Limits

Post by luke.titley »

Hey,
I've read the small article on how the D6 constraint limits are implemented and I don't really understand it.
http://www.continuousphysics.com/mediaw ... Constraint

Would I be correct in saying that when you say "linear limits" you mean limits on translation and when you say "angular limits" you mean limits on rotation?

If thats the case then does that mean ( aside from translation limits ) that at the moment in bullet you can only lock or unlock the X,Y,Z rotation axis on a D6 joint ? You can't set maximum and minimum values.

Kind Regards
Luke Titley
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA

Re: D6 Constraint Limits

Post by Erwin Coumans »

luke.titley wrote:Hey,
I've read the small article on how the D6 constraint limits are implemented and I don't really understand it.
http://www.continuousphysics.com/mediaw ... Constraint

Would I be correct in saying that when you say "linear limits" you mean limits on translation and when you say "angular limits" you mean limits on rotation?
Indeed, that is correct, linear refers to translation and angular to rotation.
If thats the case then does that mean ( aside from translation limits ) that at the moment in bullet you can only lock or unlock the X,Y,Z rotation axis on a D6 joint ? You can't set maximum and minimum values.
Kind Regards
Luke Titley
Are you using the latest version of Bullet (2.38 at this time)? You can set the lower and upper limits for all 6 degrees of freedom, see http://www.continuousphysics.com/Bullet ... raint.html

Code: Select all

void 	setLinearLowerLimit (const btVector3 &linearLower)
void 	setLinearUpperLimit (const btVector3 &linearUpper)
void 	setAngularLowerLimit (const btVector3 &angularLower)
void 	setAngularUpperLimit (const btVector3 &angularUpper)

or each of the 6 DOF limits individually, first 3 are linear, last 3 angular:

void SetLimit(int axis, btScalar lo, btScalar hi)
{
     m_lowerLimit[axis] = lo;
     m_upperLimit[axis] = hi;
}
Not all combinations are meaningful/stable, especially when combining multiple angular limits/large ranges. Note that the generic D6 constraint is relatively new and work in progress: motors and spring-damper will be added.

Erwin
luke.titley
Posts: 15
Joined: Fri Sep 08, 2006 3:39 pm

Second Question

Post by luke.titley »

If I was to visualize having set 3 finite angular limits, one on each angular degree of freedom. Could i visualize the limits in a way similar to this ?

Image

Assuming that my joint faces down the Z axis could I say that rotation was limited along the y and x axis to the area within the pyramid and rotation around the z axis was limited to the circular segment above the pyramid?
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA

Post by Erwin Coumans »

If you fix 2 angular axis, and leave a range limit on one axis, this is just a twist axis. However, if you have more then one rotational axis non-fixed, the resulting free range is non-intuitive to visualize.

Bullet follows the COLLADA Physics standard for its generic D6 constraint.
Image
You can read more about the physics specification in the COLLADA 1.4.1 specification here:
http://www.khronos.org/collada/

Also, Nima / PhysX for Maya and ColladaMaya use the same system, perhaps with different limitations:
Image
Nima and COLLADA Maya documentation at the Feeling Software website http://www.feelingsoftware.com and Ageia PhysX documentation formulate the generic D6 joint too, but details differ for the allowed range of multiple angular limits. In Bullet I recommend using x axis for full twist range, and small ranges for y and z to approximate some 'swing cone'.

I consider adding a cone-limit, that can be combined with a twist limit. That should be more intuitive.
Erwin
User avatar
Dragonlord
Posts: 198
Joined: Mon Sep 04, 2006 5:31 pm
Location: Switzerland

Post by Dragonlord »

I played now around a bit with the DOF6 constraint myself trying to get also something like a rag-doll working. I tried to start simply by first simulating a Ball-Socket constraint using the following:

Code: Select all

constraint->setLinearLowerLimit( btVector3( 0.0f, 0.0f, 0.0f ) );
constraint->setLinearUpperLimit( btVector3( 0.0f, 0.0f, 0.0f ) );
constraint->setAngularLowerLimit( btVector3( 10.0f, 10.0f, 0.0f ) );
constraint->setAngularUpperLimit( btVector3( 0.0f, 0.0f, 0.0f ) );
This worked out as I expected so I went some step further restricting motions on one of the two free axis.

Code: Select all

constraint->setAngularLowerLimit( btVector3( ONE_PI * -45.0f, 10.0f, 0.0f ) );
constraint->setAngularUpperLimit( btVector3( ONE_PI * 45.0f, 0.0f, 0.0f ) );
This also worked. I then tried to restrict also the last free axis like this.

Code: Select all

constraint->setAngularLowerLimit( btVector3( ONE_PI * -45.0f, ONE_PI * -10.0f, 0.0f ) );
constraint->setAngularUpperLimit( btVector3( ONE_PI * 45.0f, ONE_PI * 10.0f, 0.0f ) );
This worked at the beginning. Giving some push though to the limbs cause the constraints to become chaotic ( nice to look at but bad for a human for sure :lol: ).

I assume I did something wrong but I don't know what. Is it that I currently have two limited axes and one locked axis? Should I set all three axes to limited? Can I use the negative values or is this bad?
--
Pl?ss Roland
Dirk Gregorius
Posts: 861
Joined: Sun Jul 03, 2005 4:06 pm
Location: Kirkland, WA

Post by Dirk Gregorius »

Can you setup a demo so I can reproduce this?
User avatar
Dragonlord
Posts: 198
Joined: Mon Sep 04, 2006 5:31 pm
Location: Switzerland

Post by Dragonlord »

Dirk Gregorius wrote:Can you setup a demo so I can reproduce this?
:? . This is not so easy. The code where the problem occurs can unfortunately not be pulled out of the complex engine without breaking. I would have to write a separate application with the problem. Maybe I can misuse one of the Demos in bullet for this test. Problem is only that I have no idea of Jam ( I'm automake enthusiast ). Let's see.
User avatar
Dragonlord
Posts: 198
Joined: Mon Sep 04, 2006 5:31 pm
Location: Switzerland

Post by Dragonlord »

I tried now to change the ConstraintDemo to a RagDollDemo trying to show the problem. The demo works with rather large values so I had to scale the model I used ( test-humanoid with 1m equals 1.0 units ) up by ten to fit it into the demo setup.

In this setup it is more difficult to make the system to go chaotic but it works too. Reducing the model in size makes it a bit more unstable ( but not that much I expected ) and increasing the limits does increase the instability ( so far what Erwin said before ).

To test it extract RagDollDemo.tar.bz2 into the Demo directory of the bullet installation. The jam file inside should be working but you need to tweak the jam file in the Demo directory to get it build ( I'm new to jam but somehow I got it working ). Once inside the demo best is to turn the mesh around so you look from the back ( more or less ). Set then the shooting speed to 150 and shoot a couple of cubes into the knees/legs. If done right things start to explode.

You can fiddle around with the settings of the entire system by editing the lines 75 to 127. I know it's a bad big huge struct but enough for testing purpose.
---
Pl?ss Roland
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA

Post by Erwin Coumans »

The angular degrees of freedom are not independent, and the problem is caused because they are currently solved indepently. This can be easily reproduced indeed: simulating a hinge using the generic 6dof constraint will automatically lead to degenerate cases at the moment.

Some heuristic rules needs to be added for the generic 6DOF constraint to work with various angular DOF combinations. These rules will be based on the number of fixed/free angular dofs and ranges of angular limits.

Another addition for all constraints will be motors and cone limits. This would make the point to point and hinge constraint useful for ragdolls too.
Erwin