Shaking bodies

A place to discuss everything related to Newton Dynamics.

Moderators: Sascha Willems, walaber

Shaking bodies

Postby Bird » Mon Nov 28, 2011 3:50 am

I'm seeing some shaking bodies in my simulation. Here's a brief video that shows the problem. http://www.hurleyworks.com/media/flash/Shaking/Shaking.html
I can reduce it with linear and angular dampening but what's the cause and how can it be prevented? My project supports PhysX too and it happens there too as well soI think it's probably a problem on my end.

-Bird
Bird
 
Posts: 636
Joined: Tue Nov 22, 2011 1:27 am

Re: Shaking bodies

Postby Julio Jerez » Mon Nov 28, 2011 8:53 am

teh shaking happen because the small pieces has the cente of mass outsize the shape.
when you chare the small pieces you need to reacalculate the center of mass and the inertica of each piece.
if the parameter are corrent the shoudl be zero shaking. at least in newton that hwo it should be.
are you doing that?
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Shaking bodies

Postby Bird » Mon Nov 28, 2011 7:24 pm

Julio Jerez wrote:teh shaking happen because the small pieces has the cente of mass outsize the shape.
when you chare the small pieces you need to reacalculate the center of mass and the inertica of each piece.
if the parameter are corrent the shoudl be zero shaking. at least in newton that hwo it should be.
are you doing that?


Yes, I think I did that part correctly. I made a visual display for center of mass and it looks correcthttp://www.hurleyworks.com/media/flash/VisualCenterOfMass/VisualCenterOfMass.html

I also tried calling NewtonBodySetCentreOfMass with dVector origin(0, 0, 0, 1) and I also tried not calling NewtonBodySetCentreOfMass at all to let Nwton figure it out but there is still shaking.

-Bird
Bird
 
Posts: 636
Joined: Tue Nov 22, 2011 1:27 am

Re: Shaking bodies

Postby Julio Jerez » Mon Nov 28, 2011 8:35 pm

OK, before we do anything, see if you can shop the contact points.
I believe there is a reason why is does, that. But firs I like to see if the contact is stable.
There is code in the sdk demo that shows how to render the contacts point.
I like to see if the position of the contact is stable.

Basically what is happening is that the convex is resting of the surface of a sphere, therefore it getting only on contact. The contact will be unstable and the convex should lean to one side and roll over that contact, but if the contact is intermittent because the contact material is making the body to do tiny bouncem then it may show that behaviours.
Please try displaying the contact and also what the material are at that point.

one think I forget to ask, is that if the round object on that the convex pieces are falling on is a big sphere?
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Shaking bodies

Postby Bird » Tue Nov 29, 2011 5:02 pm

Julio Jerez wrote:OK, before we do anything, see if you can shop the contact points.
I believe there is a reason why is does, that. But firs I like to see if the contact is stable.
There is code in the sdk demo that shows how to render the contacts point.
I like to see if the position of the contact is stable.

Basically what is happening is that the convex is resting of the surface of a sphere, therefore it getting only on contact. The contact will be unstable and the convex should lean to one side and roll over that contact, but if the contact is intermittent because the contact material is making the body to do tiny bouncem then it may show that behaviours.
Please try displaying the contact and also what the material are at that point.

one think I forget to ask, is that if the round object on that the convex pieces are falling on is a big sphere?


Yes, the round object is a big sphere.

I'm able to get the contact points and normal from Newton ok but I also want to know the contact force ... but it always comes back dVector(0,0,0). Here's the code I'm using taken from the sdk example and my simple test scene is just a ball falling onto a box. I tried to extract contact forces in the SDK BasicFriction demo and it worked perfectly so I must be missing something in my own scene. While debugging I can see that material.m_normal_Force, material. m_dir0_Force and material. m_dir1_Force are all 0 no matter how hard the ball appears to hit the box.

-Bird

Code: Select all
NewtonBody* const body0 = NewtonJointGetBody0(joint);
NewtonBody* const body1 = NewtonJointGetBody1(joint);

for (void* contact = NewtonContactJointGetFirstContact (joint); contact; contact = NewtonContactJointGetNextContact (joint, contact))
{
   
      dVector point;
   dVector normal;   
   NewtonMaterial* const material = NewtonContactGetMaterial (contact);
   NewtonMaterialGetContactPositionAndNormal (material, body0, &point.m_x, &normal.m_x);

   dVector contactForce;
   NewtonMaterialGetContactForce(material, body0, &contactForce[0]);
}
Bird
 
Posts: 636
Joined: Tue Nov 22, 2011 1:27 am

Re: Shaking bodies

Postby Julio Jerez » Tue Nov 29, 2011 5:32 pm

For now let us no worrie abuot the contact getting the forces in the same frame. Ther are way to do that but it is no critical for this problem.

see if you can display the conctact normal and position in a video, i just want to see if they are consistent adn the part is no dosin micro jumps.
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Shaking bodies

Postby Bird » Tue Nov 29, 2011 6:31 pm

Julio Jerez wrote:For now let us no worrie abuot the contact getting the forces in the same frame. Ther are way to do that but it is no critical for this problem.

see if you can display the conctact normal and position in a video, i just want to see if they are consistent adn the part is no dosin micro jumps.


Ok, here's the video. I simplified down to 1 piece.http://www.hurleyworks.com/media/flash/Shaker/Shaker.html

I don't know if it makes a difference or not but I'm calling NewtonUpdate using 4 substeps for each frame: In my application the user usually wants a frame rate of 30fps so I call NewtonUpdate 4 times with maxTimeStep = (1/30.0f)/4.

-Bird

Code: Select all
// advanceSimulation
void Newton3Engine::advanceSimulation (float timeStep)
{   TRACE("Newton3Engine::advanceSimulation")

   ++currentFrame_;

   for( int i = 0; i < 4; i++ )
      NewtonUpdate (world_, maxTimeStep_);
}
Bird
 
Posts: 636
Joined: Tue Nov 22, 2011 1:27 am

Re: Shaking bodies

Postby Julio Jerez » Tue Nov 29, 2011 9:15 pm

Excellent, this is exactly what I was expecting to see, I ask to see the normal before I say anything because want to make sure there was not a bug.
There is no bug. It is difficult to understand but this is one of these erase cases when that the correct physics cal behavior. I will explain to you and tell you how to work around that.

Basically the convex is falling of a surface that can only generate one contact. Because the contact is produced that the surface of a sphere, the contact wills the direction of the contact will always pass by the center of the sphere, but with the exception of a perfect regular convex, the contact will not pass by the center of the convex solid.
When this is the case the reaction force will be a force aligned to the contact normal by that will no pass but the center of mass of the solid, therefore generation a net nonzero torque the will spin the body.

The body will roll over the contact point gaining some angular are velocity, basically convert potential energy to angular energy, the energy will make the body reach another apex point and at the point the force still point alone the contact but because the distance for the lone of action to the center is on the other extreme, then the torque change direction making the body swing back,
That is what is called a conservative system, example of that is Pendulum, Spring system with no damper, a body bobbing up and down a fluid.
In the absent of any friction or drag force to drain the kinetic energy from the system, then the system will oscillate indefinitely.

You can do this,
-make a material and reduced the static and dynamic friction, to allow the body to slide on the sulfate of the sphere until it falls to the ground.
-In the material call back you can apply some angular velocity base grad toque to the body so that the damp the kinetic angular energy.

that video is actually a quite correct physical simulation of teh ideal case, and with out Drag it will not stop.
and like I said before it is one of the rare case whe the oscilation is correct.
that oscilation is no shake, or jitter, it is potencial to kenetic energy tranfer.
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Shaking bodies

Postby Bird » Wed Nov 30, 2011 10:35 am

Excellent, this is exactly what I was expecting to see, I ask to see the normal before I say anything because want to make sure there was not a bug.
There is no bug. It is difficult to understand but this is one of these erase cases when that the correct physics cal behavior. I will explain to you and tell you how to work around that.

Glad to hear it's not a bug...I'm sure the artists will think otherwise though. :) But at least now I can provide them with an explanation and workaround ... so thanks for that.

For now let us no worrie abuot the contact getting the forces in the same frame. Ther are way to do that but it is no critical for this problem.

Could you please tell me how to do that now?

-Bird
Bird
 
Posts: 636
Joined: Tue Nov 22, 2011 1:27 am

Re: Shaking bodies

Postby Julio Jerez » Wed Nov 30, 2011 12:23 pm

the quickest and dirty solution is to make a material tah relate the sphecical object with the solid, and ther set the dynamics and static fition to a low value.
the default friction I beleieve is 0.6, teh will make the solid stick to the surface, stiing to 0.1 or something like that will provide some friction, and will allow the solid to slid to the ground as they swin for an back.
but since newe contact are a lower position the body will be goin under lat of kenetic energy transfer and the consevative effect will not be ready.

if you think about, a solid object can not stand of on the surface of a small sphere, unless the object has more than one point of contact. but rigid bodies do not deform so the will exibit that behavior.
in real life on a very large sphere the effect should diminich when the box is close to the pole because the curvature there resemble a flat surface and the body can probably pick more than one contact,
however in a real time physi engine the sphere is ideal object and the collision system will report just one contact, those are the sacrifices we have to accept when we make the asumptions that the body is ridid.
and we aproximate the world with idea chapes.
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Shaking bodies

Postby Julio Jerez » Wed Nov 30, 2011 12:31 pm

Bird wrote:
For now let us no worrie abuot the contact getting the forces in the same frame. Ther are way to do that but it is no critical for this problem.

Could you please tell me how to do that now? -Bird


Let me complete the other problem first, the functionality is there for joints, but I did not added for bilateral joints and not for contacts.

NEWTON_API void NewtonUserJointSetFeedbackCollectorCallback (const NewtonJoint* const joint, NewtonUserBilateralCallBack getFeedback);

bilareal joints and contact are both joints in newton but, I will have to move the callbak to teh joinbt base class, and then add a material function.

that way you can create a material and set up the callback and hen teh engine will mak ethe call on teh same frame.
ther reason it was no like that in the first place is that contacts as opposet to joint are created bu and maintan by the engine,
and the user control then induretly with material.

it is a trival change, and a realy good one for teh engine, but you have to let me complete the other thing first, you go faster than I can keep up.
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Shaking bodies

Postby Bird » Wed Nov 30, 2011 2:02 pm

it is a trival change, and a realy good one for teh engine, but you have to let me complete the other thing first, you go faster than I can keep up.


Sorry, I don't mean to rush you. Please take your time! I've got plenty of areas to work on to keep me busy. :)

-Bird
Bird
 
Posts: 636
Joined: Tue Nov 22, 2011 1:27 am


Return to General Discussion

Who is online

Users browsing this forum: No registered users and 1 guest

cron