# Physics Simulation Forum

 All times are UTC

 Page 1 of 1 [ 12 posts ]
 Print view Previous topic | Next topic
Author Message
 Post subject: Iterative Dynamics :: PGS solverPosted: Fri Nov 25, 2005 10:19 am

Joined: Fri Nov 25, 2005 10:09 am
Posts: 34
http://rafb.net/paste/results/DXkCXl35.html
here is my attempt to create PGS solver. Quite strange that joints in this case a little bit unstable ( some 'jittering' introduced during simulation of chain of spheres, connected via Ball-&-Socket joints and attached to World ). Before this attempt i had slower method but joints worked stable in this way ( there was some issues in other places ).
So, the problem: at first, there is no force, applied to the bodies. ( think it goes from Lambda = 0-vector; a = B*Lambda hence it's 0-vector too ). Second problem: if i set Lambda as 0-vector and a as Fext*M^-1, gravity acts normally, but joints have jittering and very unstable ( even if i disable Collision Detection&Response ).

Top

 Post subject: Posted: Sat Nov 26, 2005 6:34 am

Joined: Fri Jul 01, 2005 5:29 am
Posts: 323
Location: Irvine
First of all, make sure the solver converges to the correct solution for a static chain hanging straight down. Each lambda should equal the weight that the constraint supports. Start with one link, and then increase the number of links.

Also, make sure your Baumgarte parameter is not too large. I use 0.1.

When I first coded my PGS solver I got instabilities for chains. The trick with PGS is to use balanced inertia tensors. Make sure that the lengths use to compute the inertia tensor are at least as large as the link lengths. I have a chain of 8 boxes that is very stable, even with collision.

Keep in mind that inertia tensors don't need to match reality (in games at least). So they are can be artificially inflated to increase stability drastically with minimal effect on the visual quality of the motion.

Stability for joints can be improved further by relaxing the lambdas. Before beginning the PGS iterations, set

lambda *= relaxation, where relaxation in [0,1]

I usually pick a relaxation value between 0.9 and 1.0. The relaxation helps to damp oscillations in the constraint forces.

Top

 Post subject: Posted: Sat Nov 26, 2005 5:10 pm

Joined: Fri Nov 25, 2005 10:09 am
Posts: 34
Hey! That was you who've written that paper! Cool..
Yes, hanging down chain simulates correctly ( both from visual and data standpoints )... ( 4 linked spheres )
I want to notice that i don't use Baumgarte stabilization yet ( how many stability gives this method? )
( About balanced i.t. ) That's not too good, is there some other issues on theme? That'll be too painy to racalc tensors for each link when several connected bodies and length varying greatly...
And about relaxation: initial guess is that lambda is 0-vector, so before beginning PGS iterations multiplying lambda will not give anything... Or i have wrong understanding...

Top

 Post subject: Posted: Sat Nov 26, 2005 10:35 pm

Joined: Fri Jul 01, 2005 5:29 am
Posts: 323
Location: Irvine
Using Baumgarte or some other positional correction is necessary to keep the joints from drifting apart. However, even without Baumgarte, my simulation does not explode or jiggle.

If the lengths vary, then you may have other problems. The chain will not be stable if the link to ground is lighter and shorter than the next links. PGS reflects exaggerated real world instabilities. Consider connecting a 1 cm, 1 gram link to ground then next a 10 meter, 100 kg link. It is likely that the small link will break. PGS shows a similar instability in such configurations. However, if the links are reversed, heavy then light, stability is obtained both in the real world and with PGS.

You should store the joint's lambda values across steps. This will reduce the number of necessary iterations and let you increase the time step. I can simulate an 8 link chain at 30Hz and 5 iterations with no problems.

Top

 Post subject: Posted: Sun Nov 27, 2005 8:57 am

Joined: Thu Aug 18, 2005 6:27 pm
Posts: 34
Erin Catto wrote:
You should store the joint's lambda values across steps. This will reduce the number of necessary iterations and let you increase the time step. I can simulate an 8 link chain at 30Hz and 5 iterations with no problems.

That's amassing and extraordinary. I am using ODE and when I make a simple ragdoll (11 limbs, body part heavier than limbs), I find that to get anything stable I need to go over 100 iterations and I run the simulation at a fix step of 100 Hz. Even at that setting each when the doll collides hard with the floor it suffer dismembering.
The implementation of the Gauss-Seidel in your paper seems to be the same as the one in ODE without the SOR part. It is there anything I am missing, because at 30 Hz I cannot even manage to get a simple pendulum at 100 iterations and you say you can have it with just 5.

Top

 Post subject: Posted: Sun Nov 27, 2005 11:36 am

Joined: Fri Nov 25, 2005 10:09 am
Posts: 34
Well, i have another kind of instabilities... Chain now works OK ( i've reduced number of PGS iterations from 10 to 1... that's quite strange :: should be the other way - decreasing number of iterations leads to more instability issues ), BUT ragdoll with ball-&-socket joints instead of hinges ( and with them also ) looks strange: it falls on the ground ( made from 20 spheres ) and after falling tries to get fixed position ( because of spheres instead of plane ) and then several joints makes capsules ( that's legs and hands ) to jitter and cause instability. I can't understand why it's happens. Especially that iterations-reducing stability... Seems like i introduced some bugs into your algo

Top

 Post subject: Posted: Sun Nov 27, 2005 10:36 pm

Joined: Fri Jul 01, 2005 5:29 am
Posts: 323
Location: Irvine
I also simulate ragdolls just fine at 30Hz and 5 iterations. My engine benefits from contact caching (which ODE lacks). But that's not the whole story.

Try to use capsules for the limbs, this makes the collision smoother. For the mass use capsule inertia tensors, but scale it up. I use a factor of ~8. Also, make sure your lengths match human dimensions and that gravity is correct. If you use high gravity, then you will need a small physics step.

Our game runs at 30Hz and mostly at 5 iterations, so it can be done. However, we don't stack boxes higher than 3 or 4. Those small stacks are very stable.

Top

 Post subject: Posted: Mon Nov 28, 2005 12:05 am

Joined: Thu Aug 18, 2005 6:27 pm
Posts: 34
Erin Catto wrote:
I also simulate ragdolls just fine at 30Hz and 5 iterations. My engine benefits from contact caching (which ODE lacks). But that's not the whole story.

Try to use capsules for the limbs, this makes the collision smoother. For the mass use capsule inertia tensors, but scale it up. I use a factor of ~8. Also, make sure your lengths match human dimensions and that gravity is correct. If you use high gravity, then you will need a small physics step.

Our game runs at 30Hz and mostly at 5 iterations, so it can be done. However, we don't stack boxes higher than 3 or 4. Those small stacks are very stable.

Well I can only say congratulation you have done something no body has been able to accomplished. I believe I have near perfect contact catching and I also use capsule with proper inertial tensor but I had never been able to have a stable simulation at 30 hz regardless of any thick I could apply.
When I set a chain of say 8 or 10 bodies, at five iteration per step the last row of the system matrix hardly get any influence from the iteration process(in my case).

Your engine must be awesome, because in all my experience dealing with physics engine, my own and third party, I never came across a method capable of solving a large set of articulate bodies at such low frequency. It almost defy Niquist frequency criteria.

Top

 Post subject: Posted: Mon Nov 28, 2005 1:32 pm

Joined: Fri Nov 25, 2005 10:09 am
Posts: 34
I'm using capsules instead of limbs. Sphere is just head ( torso's representation is capsule too ). Dimensions is look fine. If it'l be not too hard for you, tell me please some links on PGS ( maybe not in physycal meaning ), i want to dig deeper to find out error. I think that this comes from mine lack of understanding so i need to study deeper to correct my conception about PGS...
P.S.
Gravity is (0, -9.81f, 0)
and dt = 0.004f;

Top

 Post subject: Posted: Mon Nov 28, 2005 11:30 pm

Joined: Fri Jul 01, 2005 5:29 am
Posts: 323
Location: Irvine
Try simulating a single link with a small sphere at the tip and compare the result with the ideal pendulum equation:

d^2 theta / dt^2 + (g/L) sin theta = 0

You can write a simple program to integrate the pendulum. Check the position and velocity.

Top

 Post subject: Posted: Tue Nov 29, 2005 4:26 pm

Joined: Fri Nov 25, 2005 10:09 am
Posts: 34
I have stable Gauss-Seidel method ( due to kenny's paper ) with Cholesky Factorization ( Alkire's paper ). But it's slow. I think that i need to optimize it ( like you've done that in your paper ). But i need to do it bymyself ( invent a bicyclke ) because i have lack of understanding what bugs i've introduced to your algo. In the same configurations slow GS works very stable in relation to PGS. So i think it's my fault and i need to do all the optims by my own hands.

Top

 Post subject: Posted: Thu Dec 01, 2005 7:36 pm

Joined: Fri Nov 25, 2005 10:09 am
Posts: 34
Hello again.
Recently i've decided to follow your (Erin) path and make optimizations ( with full algebraic transformations ) by my own hands. Quite strange, but i've received same formulas as you! ) And i've made SOR PGS solver due to this formulas and that works! I don't know where i've made some bugs in previous version, but this is fact - your optimizations works well and gives very big performance boost! I just want to say "Thank you" from all newbie physsim developers from all over the world!

And now, back to theme
I've wrote that your sim have quite stable simulation with 5 iterations and 60 Hz. My results: stable results only above 25 iterations and with stepsize 0.004 ( that's equal to a frequency of 250 Hz if i've right understanding ). But i still not use contact caching and lambda0 ( initial guess ) is equal to eta ( if that symbol like english n calls so ).

Well thank you again for your help.

Top

 Display posts from previous: All posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost timeSubject AscendingDescending
 Page 1 of 1 [ 12 posts ]

 All times are UTC

#### Who is online

Users browsing this forum: silmeth and 6 guests

 You cannot post new topics in this forumYou cannot reply to topics in this forumYou cannot edit your posts in this forumYou cannot delete your posts in this forumYou cannot post attachments in this forum

Search for:
 Jump to:  Select a forum ------------------ BULLET PHYSICS LIBRARY USERS    General Bullet Physics Support and Feedback    Release Announcements    Applications, Games, Demos or Movies using Bullet PHYSICS AUTHORING TOOLS, SERIALIZATION AND STANDARDS    Physics authoring tools, serialization, standards and related topics RESEARCH AND DEVELOPMENT IN COLLISION DETECTION & PHYSICS. Don't post Bullet support questions here!    Research and development discussion about Collision Detection and Physics Simulation    Links, Papers, Libraries, Demos, Movies, Comparisons       Non-technical forum and license/patent discussion    Career Opportunities