In the solver I inherited we use PGS to determine the appropriate impulse to apply to each body based on the constraint rows. What I'm confused about is that our solver runs a series of iterations, and once complete calculates the total forces for a rigid body (F = Impulse * deltaT + Fext), and applies them, integrating the velocity ( V = F * DeltaT ), and the position ( P1 = P0 + V * DeltT ) of the object. This is not done in the iteration loop, but once the loop is complete.
When I look at Erin Catto's presentations, and other simulations, it appears as if the object's velocity is updated within the iteration of the solver and the position updated at the end.
I'm not clear what the distinction between the two solvers is - or why the distinction was made - the original author of our system isn't available for comment - but I wonder which is more stable and performant?
Any input would help.
S
PGS accumulating impulses vs applying each step
-
- Posts: 38
- Joined: Mon May 06, 2013 6:14 pm
-
- Posts: 231
- Joined: Tue Feb 20, 2007 4:56 pm
Re: PGS accumulating impulses vs applying each step
For the subsequent iterations to actually do something useful, I think the velocity has to be updated and stored somewhere. But it's possible that it is not being stored in the rigid body object itself. Are you sure that the velocity isn't being copied somewhere before the first iteration (for example, to a solution matrix), and used from that auxiliary location?
-
- Posts: 38
- Joined: Mon May 06, 2013 6:14 pm
Re: PGS accumulating impulses vs applying each step
Bone,
It is accumulating something each step, but it appears it is accumulating linear and angular impulse components, not velocities, unless I am reading the code and the comments wrong - I wish I could share more code but I can't. What confuses me is that none of he solver rows are recalculated after each iteration - for example, in box2d, after each step the constraint is re-evaluated. In our system once the solver rows are created from the constraints they are unchanged during the iterations. They appear as generic rows with linear and angular components for A & B bodies, min and max clamping, current lambda, and some other terms with no tie back to the original constraints.
I'll sit down and compare the maths with some papers again and see if it is just a difference in terminology.
Thanks
It is accumulating something each step, but it appears it is accumulating linear and angular impulse components, not velocities, unless I am reading the code and the comments wrong - I wish I could share more code but I can't. What confuses me is that none of he solver rows are recalculated after each iteration - for example, in box2d, after each step the constraint is re-evaluated. In our system once the solver rows are created from the constraints they are unchanged during the iterations. They appear as generic rows with linear and angular components for A & B bodies, min and max clamping, current lambda, and some other terms with no tie back to the original constraints.
I'll sit down and compare the maths with some papers again and see if it is just a difference in terminology.
Thanks
-
- Posts: 231
- Joined: Tue Feb 20, 2007 4:56 pm
Re: PGS accumulating impulses vs applying each step
Well, it probably needs to accumulate the impulse for other purposes (limits, warmstarting, constraint breakage, debugging, etc.). But I personally don't know how a PGS solver could work without updated velocities each iteration.
-
- Site Admin
- Posts: 4221
- Joined: Sun Jun 26, 2005 6:43 pm
- Location: California, USA
Re: PGS accumulating impulses vs applying each step
Sequential Impulse is mathematically equivalent to Projected Gauss Seidel, it is just an implementation detail where to store the accumulated impulse (also known as delta velocity, acceleration or Lagrange multiplier).
Here is a screenshot of a slide of my recent presentation at SIGGRAPH that could help you clarifying it.
Either you re-compute the delta based on the body velocity (projected onto the normal/Jacobian) or you use the x vector.
When storing the applied impulse in the rigid body using apply impulse, you basically convert the impulse into world space. THen you have to project the velocity back in constraint space using the dot project. When using plain PGS, this conversion is not needed.
Here is a screenshot of a slide of my recent presentation at SIGGRAPH that could help you clarifying it.
Either you re-compute the delta based on the body velocity (projected onto the normal/Jacobian) or you use the x vector.
When storing the applied impulse in the rigid body using apply impulse, you basically convert the impulse into world space. THen you have to project the velocity back in constraint space using the dot project. When using plain PGS, this conversion is not needed.
You do not have the required permissions to view the files attached to this post.
-
- Posts: 38
- Joined: Mon May 06, 2013 6:14 pm
Re: PGS accumulating impulses vs applying each step
Erwin,
Thanks for the reply.
I suspect that there is a language issue in my code then because it does solve for the LaGrange multipliers but the maths are different to your example. Certainly there is a projection of each body's accumulated linear and angular impulses onto each row's jocobian. What I am concerned about is that the LaGrange multipliers are accumulated and applied to the body after the iterations are run, and nothing is updated other than the accumulated impulses. The iterations run until the maximum change in lambda across all the rows is below a threshold, or the number of iterations is has reached a maximum value.
It all seems a bit odd, but perhaps it is how things were done some time ago before we had more horsepower to update these values each iteration.
S
Thanks for the reply.
I suspect that there is a language issue in my code then because it does solve for the LaGrange multipliers but the maths are different to your example. Certainly there is a projection of each body's accumulated linear and angular impulses onto each row's jocobian. What I am concerned about is that the LaGrange multipliers are accumulated and applied to the body after the iterations are run, and nothing is updated other than the accumulated impulses. The iterations run until the maximum change in lambda across all the rows is below a threshold, or the number of iterations is has reached a maximum value.
It all seems a bit odd, but perhaps it is how things were done some time ago before we had more horsepower to update these values each iteration.
S
-
- Site Admin
- Posts: 4221
- Joined: Sun Jun 26, 2005 6:43 pm
- Location: California, USA
Re: PGS accumulating impulses vs applying each step
This is exactly what happens in PGS, as you can see in the right part of my previous slide. You only need to update the Lagrange multiplier (x in that code). It is perfectly fine to update the velocity of the object after you are done solving. What is unclear about this?sphet wrote:What I am concerned about is that the LaGrange multipliers are accumulated and applied to the body after the iterations are run, and nothing is updated other than the accumulated impulses.
-
- Posts: 38
- Joined: Mon May 06, 2013 6:14 pm
Re: PGS accumulating impulses vs applying each step
I apologize for not having grasped what was happening in your slide, as it relates to the code I am looking at. It does indeed now make sense.
What advantages does sequential impulse have over PGS?
What advantages does sequential impulse have over PGS?