Problem using motorized cone twist constraint

lesliei
Posts: 2
Joined: Sun Mar 28, 2010 4:43 am

Problem using motorized cone twist constraint

Post by lesliei »

First, let me say I'm having a lot of fun learning Bullet. What a great library!

My question: Can someone please help me with getting a motorized cone twist constraint to work?

I modified the ragdoll demo to show the problem I'm running into. If I motorize the left hip joint, and set the target orientation to identity, everything works fine. But if I set the rotation part of "localA" and "localB" (the transforms that locate the constraint with respect to the rigid bodies) with a matrix instead of with Euler angles, the ragdolls go unstable and disappear. (Of course, setting the rotation matrix directly is unnecessary for this demo, but in my actual production code I don't keep track of rotations using Euler angles, so I need to either set the rotation using a matrix or quaternion.)

Attached is my modified RagdollDemo.cpp, but here are the changes I made to the left hip:

Code: Select all

localA.setIdentity(); localB.setIdentity();    // Line 218 of RagdollDemo.cpp

// Here's where I set the rotation matrices manually...
// localA.getBasis().setEulerZYX(0,0,-M_PI_4*5); 
localA.getBasis().setValue(
-0.70710678118654746,-0.70710678118654746,0,
0.70710678118654746,-0.70710678118654746,0,
0,0,1);
localA.setOrigin(btVector3(btScalar(-0.18), btScalar(-0.10), btScalar(0.)));
// localB.getBasis().setEulerZYX(0,0,-M_PI_4*5); 
localB.getBasis().setValue(
-0.70710678118654746,-0.70710678118654746,0,
0.70710678118654746,-0.70710678118654746,0,
0,0,1);
localB.setOrigin(btVector3(btScalar(0.), btScalar(0.225), btScalar(0.)));

coneC = new btConeTwistConstraint(*m_bodies[BODYPART_PELVIS], *m_bodies[BODYPART_LEFT_UPPER_LEG], localA, localB);
coneC->setLimit(M_PI_4, M_PI_4, 0);

coneC->setMotorTarget(btQuaternion(0,0,0,1));    // I added this line and the next for the motor
coneC->enableMotor(true);

m_joints[JOINT_LEFT_HIP] = coneC;
coneC->setDbgDrawSize(CONSTRAINT_DEBUG_SIZE);
I am using Bullet 2.76 (re-downloaded today) with BT_USE_DOUBLE_PRECISION defined on Win7 64-bit.

Thanks!
Leslie
You do not have the required permissions to view the files attached to this post.
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA

Re: Problem using motorized cone twist constraint

Post by Erwin Coumans »

I'll ask Roman to look into this next week. He is more familiar with the btConeTwistConstraint and its motors.

Thanks,
Erwin
lesliei
Posts: 2
Joined: Sun Mar 28, 2010 4:43 am

Re: Problem using motorized cone twist constraint

Post by lesliei »

Awesome, thanks Erwin!