[SOLVED] btGeneric6DofConstraint: Limit in motor (1). Bug?

cmeyer
Posts: 4
Joined: Tue Aug 14, 2012 9:24 pm

[SOLVED] btGeneric6DofConstraint: Limit in motor (1). Bug?

Post by cmeyer »

Hi,

I am trying to implement PD control for physics-based animation. While playing around with the btGeneric6DofConstraint I came across a weird limit in motor 1. There is clearly no limit set by default, isLimited() returns false, but the rotation stops after a quarter revolution. If I set a limit I can only make it more narrow. After setting a higher limit than half PI the rotation will still stop after a quarter revolution. It might be interesting to note that the weight node connected to the joint is vibrating when reaching the weird limit, but stands still when at a limit set by me.

Using motor 0 or 2 for pitch and roll I can turn full revolutions. I would expect that behaviour for motor 1 too. Am I confronted with a bug here or is there something I am missing? Tested it with bullet-2.80-rev2531.zip and the recent svn snapshot (2546).

Here is the code I was using. I modified the ConstraintDemo for that:

Code: Select all

btTransform tr;
tr.setIdentity();
tr.setOrigin(btVector3(btScalar(0), btScalar(0), btScalar(0)));
tr.getBasis().setEulerZYX(0,0,0);
btRigidBody* pBodyA = localCreateRigidBody( 0.0, tr, shape);
pBodyA->setActivationState(DISABLE_DEACTIVATION);

tr.setIdentity();
tr.setOrigin(btVector3(btScalar(0), btScalar(5), btScalar(0.)));
tr.getBasis().setEulerZYX(0,0,0);
btRigidBody* pBodyB = localCreateRigidBody(mass, tr, shape);
pBodyB->setActivationState(DISABLE_DEACTIVATION);

btTransform frameInA, frameInB;
frameInA = btTransform::getIdentity();
frameInA.setOrigin(btVector3(btScalar(0), btScalar(0), btScalar(0)));
frameInB = btTransform::getIdentity();
frameInB.setOrigin(btVector3(btScalar(0), btScalar(-5), btScalar(0)));

btGeneric6DofConstraint* pGen6DOF = new btGeneric6DofConstraint(*pBodyA, *pBodyB, frameInA, frameInB, true);

m_dynamicsWorld->addConstraint(pGen6DOF, true);
pGen6DOF->setDbgDrawSize(btScalar(5.f));

// motor control        
btRotationalLimitMotor* motor = pGen6DOF->getRotationalLimitMotor(1);

//pGen6DOF->getRotationalLimitMotor(1)->m_loLimit = -SIMD_PI * 0.25;
//pGen6DOF->getRotationalLimitMotor(1)->m_hiLimit = SIMD_PI * 0.25;

motor->m_enableMotor = true;
motor->m_maxMotorForce = 1;
motor->m_targetVelocity = 1;

printf("\nmotor is limited: %s",(motor->isLimited())?"true":"false");
Any help for solving this issue is highly appreciated.
Last edited by cmeyer on Mon Aug 27, 2012 10:18 am, edited 1 time in total.
cmeyer
Posts: 4
Joined: Tue Aug 14, 2012 9:24 pm

[SOLVED] Re: btGeneric6DofConstraint: Limit in motor (1). Bu

Post by cmeyer »

OK, it is in the docs.
Y -PI/2 PI/2
I guess then I have to find a clever way to control all three angles to match the rotation coming from a quaternion.
info128
Posts: 7
Joined: Thu Mar 03, 2011 2:30 am

Re: [SOLVED] btGeneric6DofConstraint: Limit in motor (1). Bu

Post by info128 »

Just saw your post; I ran into this limitation back in May when attempting to implement a "motor-driven ragdoll" system. This just will not function due to the +/-90 degree limit in the y axis. The solution, it seems, would be to implement a quaternion-based 3DOF or 6DOF constraint. See my previous post:

6DOF Constraint: Y-axis angular limit > 90 degrees?

In short, Dirk Gregorius mentioned on another forum that he implemented a quaternion constraint system which worked well. Quaternion constraints are documented in the book "Game Physics Pearls" which I still need to purchase. I know tossing this info out on this forum is unlikely to inspire someone to implement it within the Bullet framework, but if anyone reads this and is interested, this would be an amazing addition to the Bullet library.