btSliderConstraint

Post Reply
Youne
Posts: 40
Joined: Sun Jan 27, 2008 2:55 pm

btSliderConstraint

Post by Youne » Sun Apr 27, 2008 6:49 am

Hi,

Qucik question : How do we designate the axe of translation for the two rigidbodies when we use btsliderconstraint to construct a slider between two rigidbodies ?


thanks you

Youne

Youne
Posts: 40
Joined: Sun Jan 27, 2008 2:55 pm

Re: btSliderConstraint

Post by Youne » Wed Apr 30, 2008 9:38 am

Please someone please help :( :( :(

User avatar
Dragonlord
Posts: 191
Joined: Mon Sep 04, 2006 5:31 pm
Location: Switzerland
Contact:

Re: btSliderConstraint

Post by Dragonlord » Wed Apr 30, 2008 4:05 pm

The axis of translation is always along the X-Axis. Therefore setup a transform where the X-Axis points long the direction you want to translate and feed it to the constructor. Should do the trick.

Saucetenuto
Posts: 4
Joined: Thu Apr 17, 2008 7:50 pm

Re: btSliderConstraint

Post by Saucetenuto » Wed Apr 30, 2008 4:28 pm

I've been working on this too, and I don't really understand it. I've rewritten this post a few times now, but every time I test one of my theories I easily find a counterexample. It appears that the two btTransform() arguments to btSliderConstraint() define the axis of translation, and have some effect on the relative locations of the two bodies as well. Exactly what it is I cannot tell; my experiments explode every theory I have concocted, and the relevant source is very puzzling:

Code: Select all

void btSliderConstraint::buildJacobianInt(btRigidBody& rbA, btRigidBody& rbB, const btTransform& frameInA, const btTransform& frameInB)
{
	//calculate transforms
	m_calculatedTransformA = rbA.getCenterOfMassTransform() * frameInA;
	m_calculatedTransformB = rbB.getCenterOfMassTransform() * frameInB;
	m_realPivotAInW = m_calculatedTransformA.getOrigin();
	m_realPivotBInW = m_calculatedTransformB.getOrigin();
	m_sliderAxis = m_calculatedTransformA.getBasis().getColumn(0); // along X
	m_delta = m_realPivotBInW - m_realPivotAInW;
	m_projPivotInW = m_realPivotAInW + m_sliderAxis.dot(m_delta) * m_sliderAxis;
	m_relPosA = m_projPivotInW - rbA.getCenterOfMassPosition();
	m_relPosB = m_realPivotBInW - rbB.getCenterOfMassPosition();
	<snip>
So we see that m_sliderAxis is computed from m_calculatedTransformA, but the only comment is the rather cryptic 'along X', which seems to imply that the slider axis is first computed as though it were +x, and then transformed by m_realPivotAInW to get the real axis of translation. Could it be that you're supposed to use the transform to set the axis of rotation by transforming +x? That seems baroque, but it's my best theory yet.

On preview, I see that Dragonlord endorses this theory. I'd go with it, if I were you. As for me...how does one submit patches to the bullet mainline? This interface is crazy.

User avatar
Dragonlord
Posts: 191
Joined: Mon Sep 04, 2006 5:31 pm
Location: Switzerland
Contact:

Re: btSliderConstraint

Post by Dragonlord » Wed Apr 30, 2008 4:38 pm

The X-Axis is the translation axis. Just produce a matrix ( coordinate system, relative to the object coordinate system ) in your app where the X-Axis points along the translation direction and where the position is located where the origin of the translation is ( as measured later on using the limits ). FrameA becomes this coordinate system you defined. I then create a second matrix ( frameB ) which represents the same matrix as before but relative to the parent object. Set the boolean parameter to "true" to use frameA as the master frame. Doing so things should work out correctly, at least it worked for me so far.

User avatar
rponomarev
Posts: 56
Joined: Sat Mar 08, 2008 12:37 am

Re: btSliderConstraint

Post by rponomarev » Wed Apr 30, 2008 7:31 pm

Hello,

I confirm that the slider axis is X, so the constraint solver will try to keep the same orientation for X-axis of m_calculatedTransformA and m_calculatedTransformB.

Slider constraint is a new addition and unfortunately it is not properly documented yet.
Definition of the constraint space for slider may be a little bit confusing because the members m_frameInA and m_frameInB contain more information than needed to define the slider, so you need properly set them at slider creation time to ensure that constraint limits are not broken.
Using them I just tried to keep similarity in definition of constraints (as Hinge and 6DOF).

m_frameInA is transformation from the constraint space to BodyA space
m_frameInB is transformation from the constraint space to BodyB space
m_calculatedTransformA and m_calculatedTransformB are transformation from the constraint space to world space.
Constrain limits define the maximum discrepancies between these two transforms, boolean parameter defines which frame will be used to define limits.

Hope this will help
Roman Ponomarev

kmon7485
Posts: 11
Joined: Mon Jan 04, 2010 5:48 am

Re: btSliderConstraint

Post by kmon7485 » Wed Jan 20, 2010 4:21 am

I'm still a bit confused about the axis alignment stuff, even after reading these posts.

I have a problem where I have a function, that passes a btSliderConstraint into it, in order
to find the attached bodies, their location (origin) and their axis of translation.

I understand that conventionally the axis of rotation is along the X-axis, but say if during construction
of the sliderConstraint you specified the translation along the Y-axis. How would one go about re-aligning
the axis to ensure the slider, slides along the y-axis?

Post Reply