Friction question

A place to discuss everything related to Newton Dynamics.

Moderators: Sascha Willems, walaber

Friction question

Postby Bird » Tue Mar 13, 2012 8:00 am

I made a simple scene with a box sliding down a ramp onto the ground. When all 3 bodies have friction set to .1, the simulation works as expected with both the box and the ramp sliding around in a realistic way. But if I increase the ramp friction to 1.0, the ramp stays still on the ground as expected but the box still slides freely down the ramp. I'd expect the box's motion to be effected by the new friction of the ramp but it doesn't appear to be. Here's a video: http://www.hurleyworks.com/media/flash/FrictionTest/FrictionTest.html

Here's the callback code that I'm using( mostly taken from the Newton Friction SDK demo. Can you tell me how to get the box to slow down or stop when the ramp's friction is increased?

-Bird

Code: Select all
void Newton3Engine::userContactFriction (const NewtonJoint * contactJoint,
                                         dFloat timestep,
                                         int threadIndex)
{   
   const NewtonBody* const body0 = NewtonJointGetBody0(contactJoint);
   NewtonEntity* const entity0 = (NewtonEntity*) NewtonBodyGetUserData (body0);
   Surface::Ptr surface0 = entity0->component->getSurface(0);
   dFloat friction0 = surface0->getMaterial().friction;

   const NewtonBody* const body1 = NewtonJointGetBody1(contactJoint);
   NewtonEntity* const entity1 = (NewtonEntity*) NewtonBodyGetUserData (body1);
   Surface::Ptr surface1 = entity1->component->getSurface(0);
   dFloat friction1 = surface1->getMaterial().friction;

   for (void* contact = NewtonContactJointGetFirstContact (contactJoint); contact; contact = NewtonContactJointGetNextContact (contactJoint, contact))
   {
      NewtonMaterial* const material = NewtonContactGetMaterial (contact);
      NewtonMaterialSetContactFrictionCoef (material, friction0, friction0/2.0f, 0);
      NewtonMaterialSetContactFrictionCoef (material, friction1, friction1/2.0f, 1);
   }
}
Bird
 
Posts: 636
Joined: Tue Nov 22, 2011 1:27 am

Re: Friction question

Postby Julio Jerez » Tue Mar 13, 2012 9:59 am

I could not see video, but it seem you are testing kinetic friction not static friction.
If a concept point has and no zero velocity it will be handle currently with isotropic friction
the friction force will be rotate to be aligned with the contact velocity, currently it the only physics engine that handle correct kinetic and static friction.
when the contact velocity is very small or zero then it will handle with anisotropic friction that is the friction will be decomposed into tow tangent direction to the contact point,
this is not completely correct according to the coulomb model of friction, since coulomb state that the friction should be aligned to the contact acceleration.
but the acceleration is not known at the moment of the concact, so Newton uses the two arbitrary direction. It is very realistic but not 100% correct complian with coumlomb emperical law of friction.
In the future Newton will also have an isotropic static friction model by saving the acceleration of the contact and using it to rotate the tangent direction so it will be complian in all cases.

as for you test I assume than the box is moving therefore it is in kinetic friction state, and never enter the static friction state.
In your test the is friction zero is 1.0 then kenetic friction will never be higher than 0.5

try something like

NewtonMaterialSetContactFrictionCoef (material, friction0 + somedelta, friction0, 0);
NewtonMaterialSetContactFrictionCoef (material, friction1 + somedelta, friction1, 1);
}


or even better find coefficient of friction of real material pairs so that you get an idea how static and kenetic friction relate to each other and test then out in the engine, you will see how close to the real thing newton can be.
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Friction question

Postby Bird » Tue Mar 13, 2012 12:14 pm

One thing I'm confused about in the BasicFriction SDK demo is how Newton takes into account the physical properties of *both* materials in contact when setting the coefficient of friction. In the demo, only one of the DemoEntity's friction variable is queried. Shouldn't the friction values of both entities be used to compute the COF? If a hockey puck slides across ice it will behave differently than if it slides across asphalt. How do we simulate each one in Newton?

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

Re: Friction question

Postby Julio Jerez » Tue Mar 13, 2012 1:07 pm

Ha, I see.
The demo is and old version that I made form teh tiem that lot of peopel were confused with hwoi teh engine work Newton.

To answer tah I made that demo wher one object si fix an dteh oteh is not, teh demo asume that only teh materil of the dynamics boady detremine teh friction.
The engine in fact do control Material properties by usien a Dual Graph.

bascially in teh material Graph teh node are the material types, and teh edges ar eth Mapterial pairs.

say for exampel you have thre materail type: concrete, wood, and steel.

you create teh tree materials,

the you need to add the set of each pair: wood-concrete, wood-steel, steel-concrete:
you us the material inteface for that:

then when you crate a body you assign a Materail ID: say wood, or steel
then when two body collide teh enbgine use teh tow ID to get teh edge taht link teh tow materail, and ge teh material properties for that pair.

The work weel as long as bodies are made of oen material, buy is fale baddly when for compopund and collsion tree.
Netwon Tree wiil modle teh matrial ID to teh collsion instance.
the grash will remand the same bu now when tow shape copllidn it will be teh shape the will get teh material property not the body.


if you want to see a tutorial for making a material system look at this:
http://newtondynamics.com/wiki/index.php5?title=Tutorial_201:_-_Advanced_Custom_Material_System
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Friction question

Postby Julio Jerez » Tue Mar 13, 2012 2:03 pm

Ok I saw the video now.
I believe is problem what I stated before, bassically the box has a 0.5 kenetic frition, and it does no have time to slowe down enough until for teh static frition to engage.

in your dialog, you new to make two pane, one for each materialand one for making the material pair.
then when you create the body you simple apply one materil ID to teh body (untill I mopve teh matrial to teh shape)

in the materil palin is just id or label, liek concratte, metal, etc.
in the matreal pair is simular to the pane you have now.
also when you set friction do not make one friction value you nee to put two independent entry one for kinetic frition and one for static frition.

doing like that an dteh Hooky exmaple can be reproduce with high fidelity 100%.
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Friction question

Postby Bird » Tue Mar 13, 2012 2:25 pm

if you want to see a tutorial for making a material system look at this:
http://newtondynamics.com/wiki/index.ph ... ial_System

Thanks, that looks like it could work for me, I'll check it out

I'm sure Julio doesn't need any physics refreshers, but if there's anyone else like me, who can't remember his last physics course, I've found Khan Academy a great resource for learning ... well just about anything. :) http://www.khanacademy.org/

Here his short video about static and kinetic friction http://www.khanacademy.org/science/physics/v/intuition-on-static-and-kinetic-friction-comparisons

-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 2 guests

cron