Iterative Dynamics

Please don't post Bullet support questions here, use the above forums instead.
rob42lou
Posts: 2
Joined: Sun Jun 12, 2011 11:04 pm

Iterative Dynamics

Post by rob42lou »

Hi,

So I've been reading up on constraints on here and around the internet, and i've read a few papers on the subject. After awhile I found exactly what I needed, but some of what http://www.bulletphysics.com/ftp/pub/te ... namics.pdf is going right over my head and I was hoping someone might be able to help clear up some confusion.

What I'm trying to do is implement a constraint system in a 3d multibody system. Meaning the constraints will have to deal with more than pair-wise constraints. Iterative Dynamics allows this with a variable size Jacobian Matrix. However how to implement it is beyond me. As far as I can tell, you need the following infomation from the multiple bodies:

Position (Vector form)
Rotation (Quaternion form)
Velocity (Vector form)
Angular Velocity (Vector form)
Mass (Number)

Now the paper does talk about multibody systems, and gives equations that allow for multiple bodies. Then it goes on to show how a distance constraint is derived, but the paper loses me once it hits computing the Jacobian, as it throws multibody out the window in favor of 2 bodies, p1 and p2.

For the distance constraint it says Cdist = 1/2 [(p2 - p1)^2 - L^2]
How could you improve upon that to include multiple bodies?

Further down it gives pseudocode, and talks about Jmap and Jsp, what's the difference between the 2?
spidersharma
Posts: 5
Joined: Mon Jul 04, 2011 12:42 pm

Re: Iterative Dynamics

Post by spidersharma »

Hi,

I have also recently started exploring constraint dynamics and read a few papers( including the one you have mentioned).
we can say that if we have information about all pairs(2 bodies) of bodies which are constrained through a constraint, then we can solve each of the constraint independently, provided we do a few iterations.
so assume that you have 3 bodies. body 1 and 2 are connected by distance constraint, and similarly body 2 and 3 and 1 and 3.
now if you see this system as a whole, it is a multibody system.
now as far as number of constraints are concerned, we have 3 constraints. 1-2, 2-3, 1-3.
now if we make sure that one of the constraint is obeyed( that is we solve for one constraint at a time), we may weaken(break) the other two constraints.
however if we iterate through the above 3 constraints a few times, it seems that we will converge to a global solution.
so actually we do not need to modify the pair wise constraints to include multiple bodies.

Jmap stores the body index while Jsp stores the actual Jacobian block matrix.

sorry if the above is not clear.
rob42lou
Posts: 2
Joined: Sun Jun 12, 2011 11:04 pm

Re: Iterative Dynamics

Post by rob42lou »

Oh thank you! It's very clear.

It just seems like iterating multiple times is inefficient. In your example with 3 bodies, you have 3 constraints, 1 - 2, 2 - 3, 1 - 3.
Is it possible to solve the 1 - 2 constraint, and then since 1 - 2 is solved, treat objects 1 and 2 as one object (combined mass, calculate center of mass), and solve the constraint for 3 as (1&2) - 3. I figure a system like this would scale nicely when using recursion.
spidersharma
Posts: 5
Joined: Mon Jul 04, 2011 12:42 pm

Re: Iterative Dynamics

Post by spidersharma »

If you first solve constraints for body 1 and 2, and if you combine them and solve combined body and the 3rd body, it will lead to an invalid configuration.
so for example the third body's center can be at any point on a circle which is having combined body as a center.
but this is not a valid configuration, because we know from the constraints that the third body should maintain constant distance from both body 1 and 2.

what is interesting to note that is that the above system of constraints can be solved simultaneously. in fact in general a system of constraints can be solved simultaneously or iteratively.
Though it is the Iterative solution which is faster( though less accurate) than the Simultaneous solution.
the error can be reduced by doing more iterations at the cost of speed. generally for games iterative solutions are better, as we do not need very high accuracy.