Monitoring forces between rigid bodies

Post Reply
Ehsanizadi
Posts: 72
Joined: Mon Dec 02, 2013 4:13 pm

Monitoring forces between rigid bodies

Post by Ehsanizadi »

Hi,

In the hello world example I am trying to monitor forces between the falling sphere and the ground.

So I added this command in the simulation loop:
cout<<"Fz= "<< fallRigidBody->getTotalForce().getZ() <<endl;
But I get always the force of "Fz= 0". Even after sphere collided the ground!
whats the problem?

(Note: I already set z as the vertical axis)
Basroil
Posts: 463
Joined: Fri Nov 30, 2012 4:50 am

Re: Monitoring forces between rigid bodies

Post by Basroil »

Ehsanizadi wrote: But I get always the force of "Fz= 0". Even after sphere collided the ground!
whats the problem?
m_totalForce is an internal variable used to calculate how much force is accumulated in one stepping, and therefore is set to zero once you call stepsimulation(). If you want to find out the total force at the end of each step, you'll need to add a function for that directly into the solver code (just copy m_totalForce before it's deleted). Just remember that an object at rest produces zero force at the center of gravity, so you'll only get a non-zero result when the velocity changes (moment of impact only, once it stops it's back to zero)
Ehsanizadi
Posts: 72
Joined: Mon Dec 02, 2013 4:13 pm

Re: Monitoring forces between rigid bodies

Post by Ehsanizadi »

Basroil wrote: m_totalForce is an internal variable used to calculate how much force is accumulated in one stepping, and therefore is set to zero once you call stepsimulation(). If you want to find out the total force at the end of each step, you'll need to add a function for that directly into the solver code (just copy m_totalForce before it's deleted). Just remember that an object at rest produces zero force at the center of gravity, so you'll only get a non-zero result when the velocity changes (moment of impact only, once it stops it's back to zero)
Thank you Basroil,
Because I am very new to Bullet, I'm asking this: To add a function as "force collector" within the solver to collect all forces, I should do it in "btDiscreteDynamicsWorld.cpp" before the compilation, shouldn't I?

Another important question:
From your comment, it is clear that "m_totalForce" is the parameter that gets the "resultant" force applied on each rigid body.
However, if somebody is seeking for "interaction forces"*, is there any way to monitor it?

-------------------------------------
*more explanation on interaction forces:
Assume there is a cube on the ground with mass of 1kg (assume g=-10). the force applied on the cube , imparted from the ground, is 10 N.

If 2 identical cubes are going to be placed on top of that, the interaction forces between the bottom cube with ground will be: 10N x 3 = 30 N

-------------------------------------

In contrast to m_totalForce parameter, interaction forces tend to be non-zero when they are stopped and become larger when they are under pressure when they are static.


You may ask "what are you looking for such thing?"
The answer is that I am using Bullet for an engineering research program. Maybe in future it becomes possible to optimize Bullet in such a way to make it possible for engineers to make simulations with Bullet.

I would appreciate your comments and help beforehand.

Ehsan
kingchurch
Posts: 28
Joined: Sun May 13, 2012 7:14 am

Re: Monitoring forces between rigid bodies

Post by kingchurch »

I'm not an expert on this. Intuitively the sequential impulse solver may not give you the accurate measurement of the interaction force between blocks. Reason is that it's an iterative solver that generates the necessary impulses on each body to satisfy the contact constraints. Depending on the stack height of your box piles it may take one to many steps to propagate the interaction forces across the pile. Before the pipe settles you won't read stable impulses from the bodies. As soon as the pile stablize it will sleep and zero all the impulses. So the best you can expect is to add read the impulse accumulator per frame as an estimate of the interaction force. But you will never get a stable reading of the static interaction force between bodies.

One work around is to insert a spring force element between the blocks as a force sensor. When the blocks stablize you can read the spring length multiplied with the spring stiffness coefficient to get the interaction force.
Post Reply