Extract Impulse in the contact point !

Youne
Posts: 40
Joined: Sun Jan 27, 2008 2:55 pm

Extract Impulse in the contact point !

Post by Youne »

Hi everybody

I was able to extract the applied impulses at the joints with the following function :
constraint->getAppliedImpulse()
« btSequentialImpulseConstraintSolver.cpp ln 805 »

However, at the contact points I get values that do not correspond to what I should find (for example the weight of a box = mass*gravity) with the following function :
pt->m_appliedImpulse
« btSequentialImpulseConstraintSolver.cpp ln 852 »

At the same time I would like to know what these values that I find represent if anyone knows?

So what I want is to have the values of the applied impulse at the points of contact between the objects. Does anyone know how I can get these values?

Thank you for you help

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

Re: Extract Impulse in the contact point !

Post by Dirk Gregorius »

mass * gravity is a force. You need to devide the impukse by your timestep to get the force.

With regards to the example of the box. Don't expect to find 0.25 * mass * gravity at each contact point. The contact points found with an iterative solver are not the true contact forces (though they could be), but the bodies will react dynamically correct. E.g. two diagonal contact points can have a zero contact force and the other pair 0.5 * mass * gravity. All combinations are possible. See Mirtich or Baraff to read the limitations if you are interested.
Youne
Posts: 40
Joined: Sun Jan 27, 2008 2:55 pm

Re: Extract Impulse in the contact point !

Post by Youne »

Hi Dirk,

Sorry i know that mass*gravity is a force and impulse = force * timestep
(i worked with forces that's why I am confused force and impulse)

Do you mean that I must make the sum of all impulses of contact points To get the result impulse ?
(that is what i want to extract.)


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

Re: Extract Impulse in the contact point !

Post by Dirk Gregorius »

yes, you can think of this sum as the integral over the contact area
Youne
Posts: 40
Joined: Sun Jan 27, 2008 2:55 pm

Re: Extract Impulse in the contact point !

Post by Youne »

Hi Dirk,

thank you for your replay

I made one simple example a box (mass = 10.), and I have calculated the sum of impulses applied to this box but I get value that do not correspond to what I should find (sum # mass*gravity* TimeStep)!

I don't know what i have to do !

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

Re: Extract Impulse in the contact point !

Post by Dirk Gregorius »

I cannot tell without testing. Anyway, I am interested in this too. Another example would be the constraint force of a simple pendulum. So I can offer you that I will try to reproduce these two examples and post the results here. Can you agree with this?
Youne
Posts: 40
Joined: Sun Jan 27, 2008 2:55 pm

Re: Extract Impulse in the contact point !

Post by Youne »

Hi Dirk,

Yes I agree with you

In fact I just reproduce the example of the box and after several tests I was able to extract the force by following these steps:

- At each contact point I extracted the impulse (pt->m_appliedImpulse) and I multiplied it by the coefficient C (I did several tests and I found C=10 to be more real). so F=(pt->m_appliedImpulse)*10
- I got the sum of all these Forces
- The result I got was the result of the forces applied by the box on the ground.

I do not know if I am in a good way ? what do you think about this?

I noted one problem however: The problem is that the box is never static that is to say that after a while the result was never equal to a constant.
Dirk Gregorius
Posts: 861
Joined: Sun Jul 03, 2005 4:06 pm
Location: Kirkland, WA

Re: Extract Impulse in the contact point !

Post by Dirk Gregorius »

Did you run the example with more iterations, say 200 - 1000 iterations?
Youne
Posts: 40
Joined: Sun Jan 27, 2008 2:55 pm

Re: Extract Impulse in the contact point !

Post by Youne »

You mean duration of the simulation ?
Dirk Gregorius
Posts: 861
Joined: Sun Jul 03, 2005 4:06 pm
Location: Kirkland, WA

Re: Extract Impulse in the contact point !

Post by Dirk Gregorius »

Bullet uses an iterative solver. It usually takes something like ten iterations. If you aim for exact solutions you must take more iterations. Maybe you can pass the iteration count when constructing the btWorld. You better ask Erwin about this. This would be a good test when the iterative solver converges against the analytical solution.
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA

Re: Extract Impulse in the contact point !

Post by Erwin Coumans »

Indeed, you need to multiply the sum of applied impulses by the solver iteration count, which is 10 by default. Bullet uses a fixed number of iterations that can be controlled by the developer. Higher solver iteration count usually give a more precise result.

You can access/change the iteration count through

Code: Select all

dynamicsWorld->getSolverInfo().m_numIterations = iterationCount;
Hope this helps,
Erwin