Makeing the PGS more stable

Please don't post Bullet support questions here, use the above forums instead.
Post Reply
Gabor Puhr
Posts: 11
Joined: Tue May 07, 2013 8:19 am

Makeing the PGS more stable

Post by Gabor Puhr »

Hi,

In my company we are using bullet (obviously :) ) and I had the task to make it more stable.
We are using really long chain of RB-s with big mass ratios connected with 6dofs.
One of my first problem was that when I pull one side of the chain it takes N steps before the last element starts to move. Where N is the length of the chain.
So I forcefully activated all of the joints, but because of that I have lost the freedoms.
I solved this by calculating two type of errors one for the lo limit and one for the hi limit.
During solving (in resolveSingleConstraintRowGeneric) if the deltaVel1Dotn+deltaVel2Dotn (actualimpulse) is between the two errors then I don't change the constratint (deltaImpulse:=0) otherwise I set the deltaImpulse to "compensate" the actualimpulse up to the point where it reach the limit.
(for exmaple: if (actualImpulse>c.m_rhsHi) deltaImpulse = c.m_rhsHi - actualImpulse;)
With this little modification I could achieve a big step towards stability.
It is clear that the average performance became worse, but the worst case is slower only a tiny bit. (and that matters for us)

Another comment: obviously increasing the iteration count in the solver should make everything more stable, but actually it explodes the simulation (even with doubles).
The reason of that: the compensation impulses became so big for one frame at the beginning that one of the RB moves through not just the neighbor body, but even the next to that and the penetration compensation makes everything super crazy.
This trick solves this problems automatically, because when every RB moves from the beginning the relative speeds became much smaller.
so I can now increase the iteration count wildly. (though the final solution became the NNCG)

I have checked a lot of paper, but I couldn't find similar solution.
Is it something very trivial that is why nobody mention it or It is just me who didn't find a good paper from this?

Best Regards
Gabor
Dirk Gregorius
Posts: 861
Joined: Sun Jul 03, 2005 4:06 pm
Location: Kirkland, WA

Re: Makeing the PGS more stable

Post by Dirk Gregorius »

I cannot follow everything you are describing here. Here are two general points:
1) A chain with many links is highly non-linear. This might break the Baumgarte stabilization if the timestep is too large. A rule of thumb is that taking two substeps with half of the timestep helps more in terms of stability and stiffness then doubling the iteration count.

2) It seems that Bullet can put individual bodies in an island to sleep. I would not use this. If possible deactivate this and only use islands sleeping.
Gabor Puhr
Posts: 11
Joined: Tue May 07, 2013 8:19 am

Re: Makeing the PGS more stable

Post by Gabor Puhr »

Allow me to try to explain again.

Lets assume we have three box next to each other (1,2,3) and the neighbors are connected with a 6dof constraints (1-2,2-3) in a way that all freedoms are restricted.
(So theoretically the three box should move with each other like a big box)
If I pull the one at the right side (3) (with a force for example) at the next step the a solver in Bullet will recognize that the 2-3 is violated.
Because of that it will try to solve it, but will not calculate with the (1-2). As if (1-2) constraint would not exist at all.
Because of that (2) and (3) will move only in the current step after the solving.
In the next step, because the (2) was moved the (1-2) constraint is violated so the solver will try to solve that and possibly also the constraint (2-3).
It can be seen that If I have N box next to each other connected in a similar way it takes N-1 step (or sub step) before the solver will start to solve all of them together, although it should have calculate with all of them even in the first step (sub step).
Because of that the chain of boxes will bend or stretch etc when I start to move it, but will not behave as one big rigid block.
This is my primary problem.

One can say that: OK it is not problem, the solver should calculate all of the constraints even if a few are not violated.

The problem with this: Lets change the constraint (2-3) in the upper example in a way that it allows the two boxes (2) and (3) to be separated 1 meter, but no more. So the constraint is satisfied as long as the distance between (2) and (3) is between 0 meter and 1 meter.
What Bullet solver does here: if the distance of the two boxes (2 and 3) less than 1 meter it will not calculate with the constraint (2-3). So no jacobi entry will be created.
If the distance is more than 1 meter it starts to calculate with the constraint (2-3), and set up the jacobian in a way to "pull" the (2) and (3) until the distance will be less than 1 meter.
So if we would want this constraint (2-3) to be active all the time what would be the jacobi when the constraint is satisfied? (distance between (2) and (3) is between 0 meter and 1 meter)
My guess is that there is no good Jacobi here.
So I think this is not a solution by itself.

How one would solve the primary problem?

Best Regards
Gabor
Dirk Gregorius
Posts: 861
Joined: Sun Jul 03, 2005 4:06 pm
Location: Kirkland, WA

Re: Makeing the PGS more stable

Post by Dirk Gregorius »

To make this stable you will need a direct matrix solver. You can also try to solve a weld joint as a block of 6x6 matrices. This will give you some stiffness as well.

In a real world example you would not use a weld joint, but use a compound shape with three boxes.
Gabor Puhr
Posts: 11
Joined: Tue May 07, 2013 8:19 am

Re: Makeing the PGS more stable

Post by Gabor Puhr »

Thanks. I will check a document about direct solving maybe one of them contains a solution to this problem.
Best Regards
Gabor
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA
Contact:

Re: Makeing the PGS more stable

Post by Erwin Coumans »

You could try using Featherstone and/or a direct solver (such as Dantzig or Lemke) as a block solver (as Dirk mentioned). Both are in the latest version of Bullet.

By the way, Bullet doesn't put individual bodies in an island to sleep: an island is either awake and all bodies in the island are simulated, or the island is asleep if all bodies in the island are asleep.
Post Reply