How can I make a PinJoint to keep a fixed distance

Topics: User Forum
Oct 17, 2009 at 9:34 PM

Hello,

I  almost read everything posted on this forum about joints, but I cannot figure out how to anchor to objects with a pin joint forcing them to keep their distance invariable. I already have the two objects anchored but because of their weight and the gravity applied to the system they tend to separate.

How can I force them to be together? I am using softness = 0 and a high biasFactor but the bigger the biasFactor the more weird it behaves.

 

Thanks,

JL

Coordinator
Oct 17, 2009 at 10:14 PM

What mass and gravity are you using?

Because of the nature of the joints (they are iterative and converge to a solution over time) they will not stay 100% stationary when forces are applied to them. Most times it is smaller than what we notice and all is fine, but in your case, you might put a too large force on the joint. You should try to experiment with PhysicsSimulator.Iterations (use a higher value) and see if that solves your problem.

Otherwise you need to lower the mass and forces applied to the joint. Other physics engines also have more stable constraint solvers and might cope better with large forces on large masses.

Oct 17, 2009 at 10:48 PM
Edited Oct 17, 2009 at 10:51 PM

Thanks for your answer. I will try with PhysicsSimulator.Iterations. I am using gravity = Vector2(0,1000) and mass 1.0f to 30.0f

By the way I really appreciate the effort you put on this. I would say that this engine is not only good because of its implementation but because of this forum. I almost found every single question that I had just by reading other people posts. I hope to ever have the time to dig into the engine implementation to to really understand what it does.

JL

 

Oct 18, 2009 at 1:23 AM

Hello again,

I should be doing something wrong...I tried to change the PhysicSimulator.Iterations parameter and I reduced the masses to the range (0.001 0.1) and the forces that I apply are the smallest to make my object move but I still have a weird behavior. I am trying to anchor a wheel to each end of a stick:  the wheels weight is 0.083f and the stick weight is 0.001f.  The torque applied to the wheels is (20000 * mass) and the friction coefficient is 0.3f for the wheels and 0.2 for the floor. With this torque, the wheels move very slowly (if I decrease the torque applied the wheels do not move). The result is that whenever the wheels find an obstacle the stick shakes strongly enough to look bad.

I also tried to do another example where an balloon is attached to one end of the stick and a box to the other. The balloon tends to go up and the box tends to go down. The stick gets literally crazy.

Any suggestion?

I also would like to know if box2dx is available and if you know about any other engine that handles these problems better.

Thanks

JL

 

 

Coordinator
Oct 18, 2009 at 1:26 AM

Could you send me a demo of this? The values used in the samples are what the engine likes the most. Also make sure that the timestep send to the engine is correct. Again, have a look at the samples for good values.

Oct 18, 2009 at 1:31 AM

Is there any place to get the code of the samples that you show inside the manual? (the ones of the joints and springs) Those samples are the ones that fit better with what I want to do

Coordinator
Oct 18, 2009 at 1:38 AM

Indeed. Download the source code from here and go to the Tools folder. The project should be there.

I forgot to answer your second question from before. It is getting really late here.

Box2DX still needs some development before release. The author of the code (Ihar3d) is busy working right now so the official source tree is a little behind. The version we ported reside in the source control but have a few bugs and a lot of performance issues.

If you need the code to be .net, you also have the choice of Physics2D.net. The most recent release is getting a little old, but it should be stable.