Constraint of multiple objects?

Please don't post Bullet support questions here, use the above forums instead.
Post Reply
ynm
Posts: 6
Joined: Wed Aug 14, 2013 2:36 pm

Constraint of multiple objects?

Post by ynm »

I am writing some simple physics codes, e.g the spring joint and the distant joint based on PhysX: add force/ velocity based on current state of objects. It worked with two objects connect by one joint. The problem is when multiple objects connect to a single objects, the cumulative forces of each objects cancel/ adding each other and make them very unstable and quickly explode with very high velocity.

E.g I have distant joint, basically it cancels velocity projected on link between them and add a pulse force to fix any distance error. But when multiple objects connect, they shake quite hard and then explode, I don't know how to solve this.

How do physics engines solve the constraint of multiple objects?

Regards
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA
Contact:

Re: Constraint of multiple objects?

Post by Erwin Coumans »

Are you using existing constraints, that are solved together (by PhysX) or are you manually applying external forces? Multiple constraints shouldn't cancel eachother.
How do physics engines solve the constraint of multiple objects?
Pairwise constraints should work fine, as long as they are solved together. Another way is using multi body joints, such as Featherstone. That's what we added to Bullet recently.

Thanks,
Erwin
ynm
Posts: 6
Joined: Wed Aug 14, 2013 2:36 pm

Re: Constraint of multiple objects?

Post by ynm »

Thanks,

I calculate relative position and velocity then add force/ velocity manually. I also add position correction force to push object back to original position instantly (in case of fixed joint or fixed axes) and while it works perfectly in two objects scene, it seems this instant correction makes physics very unstable when involved multiple object.

I think I need to broadcast the fixed joint force from a pair to every fixed constraint of an object, but this will make computation increase with number of objects
kingchurch
Posts: 28
Joined: Sun May 13, 2012 7:14 am

Re: Constraint of multiple objects?

Post by kingchurch »

If you just use a spring force to correct position error between each pair of bodies it will work assuming g:
1. You tune the PD constants of the spring nicely and don't attempt to correct any error "instantly"
2. Lower your simulation step size to small enough to pair with your body's mass and the spring stiffness constants

This is essentially the penalty based method used by simulator such as the ROR truck sim.

If you inclined to solve the error with impulse you can just use the sequential impulse solver directly in the engine. Does PhysX not have a distance joint to use?
DannyChapman
Posts: 84
Joined: Sun Jan 07, 2007 4:29 pm
Location: Oxford, England
Contact:

Re: Constraint of multiple objects?

Post by DannyChapman »

The 6DOF joint in PhysX is asymmetric (I find this bizarre) - it will generally be more effective if the first actor in the pair is the heavier one. This might be true of the distance constraint too.

One problem that you may have is that the constraints are generating more angular motion than is desired (due to linearisation). This can happen when there's some joint separation, and/or when the moments of inertia of the objects are small. When the system is integrated this results in the joint separating even more, and then the problem becomes worse etc, until you're left with a jittering mess.

To improve this you can encourage the solver to solve the constraint using linear forces rather than torques - either artificially increase the moments of inertia of the objects permanently, or pass in a smallish number (e.g. 0.1) to the inverse inertia scale functions on the constraint: PxJoint::setInvInertiaScale0 (and setInvInertiaScale1)

You will also get better results by: making all the parts in the chain have similar masses, using a small (constant) timestep and increasing the iteration counts (PxRigidDynamic::setSolverIterationCounts - try increasing the position iterations).
Post Reply