Constraint frames, axes, and points

ihpc
Posts: 2
Joined: Wed Jan 09, 2013 6:26 am

Constraint frames, axes, and points

Post by ihpc »

Hi,

I'm learning how to use constraints in Bullet and am having difficulty understanding how to use the constructors. I've read the source and the demos, but it's not clear to me what's going on (I'm not familiar with 3d programming). I've also tried http://bulletphysics.org/mediawiki-1.5. ... onstraints, but it doesn't explain much. I'd appreciate it if someone could help me with my questions below or point me to a resource which has the answers.

1. For hinge constraints, what do rbAFrame and rbBFrame refer to? How do they relate to pivotInA/B and axisInA/B? How do we decide which constructor to use? What is useReferenceFrameA? If a constraint is supposed to connect two bodies, does using the single body constructor mean that we have a constraint floating in the air?

2. For the slider and 6DOF constraints, what are frameInA and frameInB? Are they the same as rbAFrame and rbBFrame? What about useLinearReferenceFrameA?

Sorry if the questions seem obvious, but I'm new to 3d programming and figuring out what these functions do is difficult.

Thanks for the help!
Nickert
Posts: 25
Joined: Sat Dec 29, 2012 7:20 pm

Re: Constraint frames, axes, and points

Post by Nickert »

Haven't used them yet, but there's some information about constraints in the Bullet_User_Manual.pdf, should be in the root of your bullet folder. Maybe it'll help you.
ihpc
Posts: 2
Joined: Wed Jan 09, 2013 6:26 am

Re: Constraint frames, axes, and points

Post by ihpc »

Thanks, Nickert, but the Bullet manual doesn't go into the detail I need.
mklingen
Posts: 5
Joined: Wed Jul 25, 2012 8:13 pm

Re: Constraint frames, axes, and points

Post by mklingen »

hey, I have the same problem! (just posted a thread without noticing this one.) I believe that the refrence frames are supposed to be set such that they express the *frame of the joint* in the *respective reference frame* of each argument.

So

rbA = a transform such that the origin is the center of the joint, and the z-axis is the axis of rotation, expressed in the local frame of A.
rbB = same as above, but expressed in the B frame.

However, you shouldn't take my word for it, because I can't get this to work! I've gotten it to work for Point2Point constraints, but hinge constraints just spit out Nans whenever I try to create them.
Jonathan
Posts: 36
Joined: Sun Feb 10, 2013 6:52 pm

Re: Constraint frames, axes, and points

Post by Jonathan »

I'm wondering the same thing, just Google'd for bullet physics constraint frames and found this post... disappointing to see no clear answer. :(

It seems like if I make a transform of (0,0,5) and use that for frameA, it attaches object A to object B at the relative position 'frameA' (relative to object B). Is this the correct use of frames? (To use them as the point of attachment?)

And I am still confused about the boolean on 6DOF 'useLinearReferenceFrameA', what does that do?
sgraham
Posts: 7
Joined: Sun Aug 18, 2013 8:50 am

Re: Constraint frames, axes, and points

Post by sgraham »

I too am totally confused about "frames" and how to simply supply an offset (position) and an axis of rotation.

I was able to attach a wheel (cylinder) to a car (box), but then I tried to change the axis of rotation and realized after some really wonky results that I apparently don't know how to do that. By default, with no rotations supplied in the transform frames, I get rotation along the X axis, not the Z. I will examine my code more closely and see if it's something weird in my setup, but in the meantime...

It is frustrating that every point of documentation I have found doesn't explain what is meant by "frame" and how to get what you want. The demos are great for seeing how things should be set up, but they don't actually explain through commenting how things work. Perhaps it's time to dive into the underlying code...

I too would like to know the answer to #1 in the question posed. Can someone explain clearly what a frame (or reference frame) means in this instance and how A and B relate to each other and how I can manipulate them to act like a position + axis in the case of a btSliderConstraint or hinge for example?

And please don't use the word frame in your explanation of what frame means. All I can figure is that it must be a common term for those with Physics or Math background, but ideally we don't limit the bullet library to math/physics majors. Bullet is freaking awesome btw. Thank you to the contributors, I mean no offense in this post.

Here's to hoping for some insight!
sgraham
Posts: 7
Joined: Sun Aug 18, 2013 8:50 am

Re: Constraint frames, axes, and points

Post by sgraham »

I found a subtle bug in my matrix transform code. Things seem to make a lot more sense now. I also took a peek inside the constraint code to see what it is doing with my inputs. So hopefully this will be helpful.

It might have been helpful if the variable names were instead:
rbA = parentRigidBody
rbB = childRigidBody
frameInA = parentTransform
frameInB = childTransform

(I am aware not every constraint relationship = parent/child, it just helps me to think of it that way.)

where "parentTransform" is a transform relating to where you want the pivot point relative to "parentRigidBody" center of mass and of course the rotation (basis) attributes represent how you want the axis oriented as well. (In the case of btSliderConstraint, the X axis represents the rotational and slider axis)

The "childTransform" is a transform relating to where you want the pivot point to be located relative to "childRigidBody". You can also add an extra axis of rotation here so you can re-orient your child to face the right direction relative to the parent. In my case with a tire + car, depending on how my rigidTire was oriented depends on if I need to put a rotation here or not. I will also likely need to rotate it 180 degrees on the Y or Z axis for the tire to be facing the right direction on the other side of the vehicle.

The last variable simply flips the rigid bodies in the underlying code.. so in my book I will probably never change it, though it looks like there might be an odd case where it could be needed. Again you can look at the code if you are interested.

If I am leaving anything out or oversimplifying things, please let me know. I am still getting used to Bullet myself.