Sliding Object Behavior

A place to discuss everything related to Newton Dynamics.

Moderators: Sascha Willems, walaber

Re: Sliding Object Behavior

Postby Julio Jerez » Thu Aug 18, 2011 4:52 pm

michDS wrote:I've added this call in the material collision callback (for the puck/surface) collision, but it didn't change the results:
NewtonMaterialSetContactFrictionCoef(pMaterial, 0.05f, 0.0f, 1);

The looks right,
Just to see if it is the friction calculation cuase the side force, try both
NewtonMaterialSetContactFrictionCoef(pMaterial, 0.0f, 0.0f, 0);
NewtonMaterialSetContactFrictionCoef(pMaterial, 0.0f, 0.0f, 1);
with that the Puck must go straight because it will be frictionless, the net force should not change direction like is shows in the videos

michDS wrote:Also, could you provide me the code to display the magnitude of the friction force for the tangents? I can't find the function that would give me that.
Thanks.

I will right the function to showg the frction forces, tonight.
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Sliding Object Behavior

Postby Julio Jerez » Thu Aug 18, 2011 4:59 pm

In thsi video; http://www.digitalsmoke.us/ISUHDR.mov
I noticed that in teh beginning to move teh Puck to teh side, and It stops on teh edge of teh Track.

Is there a force, a wall or something the pushes the Puck back to the track?
I say this because I see that the net force has a side compoment when it moves parallel to the edge touching the edge, but as soon as it gets off the edge
the force is parallel to the direction of motionas it should be.
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Sliding Object Behavior

Postby michDS » Thu Aug 18, 2011 10:36 pm

Julio Jerez wrote:In thsi video; http://www.digitalsmoke.us/ISUHDR.mov
I noticed that in teh beginning to move teh Puck to teh side, and It stops on teh edge of teh Track.

Is there a force, a wall or something the pushes the Puck back to the track?
I say this because I see that the net force has a side compoment when it moves parallel to the edge touching the edge, but as soon as it gets off the edge
the force is parallel to the direction of motionas it should be.


There's no wall or anything. Initially the puck is moved to the side of the table by calls to NewtonBodySetMatrix(). Then a velocity (0, 0, -1) is applied to the puck and the physics takes over from there.

Julio Jerez wrote:Just to see if it is the friction calculation cuase the side force, try both
NewtonMaterialSetContactFrictionCoef(pMaterial, 0.0f, 0.0f, 0);
NewtonMaterialSetContactFrictionCoef(pMaterial, 0.0f, 0.0f, 1);
with that the Puck must go straight because it will be frictionless, the net force should not change direction like is shows in the videos


So I tried this, and although I got different results, the puck still didn't go straight. However, if I change my call to
NewtonMaterialSetDefaultFriction() to pass in a 0 dynamic friction, then the puck does go straight like expected. Here are some videos:

1. Without calling NewtonMaterialSetContactFrictionCoef()
http://www.digitalsmoke.us/ISUHDR.mov

2. With call to NewtonMaterialSetContactFrictionCoef(pMaterial, 0.0f, 0.0f, 1)
http://www.digitalsmoke.us/ISUHD31_new_1.mov

3. With calls to
NewtonMaterialSetContactFrictionCoef(pMaterial, 0.0f, 0.0f, 0)
NewtonMaterialSetContactFrictionCoef(pMaterial, 0.0f, 0.0f, 1)
http://www.digitalsmoke.us/ISUHD31_new_2.mov

4. Without calling NewtonMaterialSetContactFrictionCoef(), but with setting dynamic friction to 0 via NewtonMaterialSetDefaultFriction()
http://www.digitalsmoke.us/ISUHD31_new_3.mov

------

Another puzzling thing is that with the other example I had where the puck falls off the table, I still can't get it to go straight.

1. Without calling NewtonMaterialSetContactFrictionCoef()
http://www.digitalsmoke.us/ISUHDL.mov

2. with setting both static and dynamic friction to 0 via NewtonMaterialSetDefaultFriction(), and also calling
NewtonMaterialSetContactFrictionCoef(pMaterial, 0.0f, 0.0f, 0)
NewtonMaterialSetContactFrictionCoef(pMaterial, 0.0f, 0.0f, 1)
http://www.digitalsmoke.us/ISUHD31_new_4.mov

Does this give any other clues?
michDS
 
Posts: 33
Joined: Fri Aug 12, 2011 3:47 pm

Re: Sliding Object Behavior

Postby Julio Jerez » Fri Aug 19, 2011 9:04 am

This video looks correct.
4. Without calling NewtonMaterialSetContactFrictionCoef(), but with setting dynamic friction to 0 via NewtonMaterialSetDefaultFriction()
http://www.digitalsmoke.us/ISUHD31_new_3.mov

If setting teh defula contact work and overridin it on the material call back does not then there most be a bug some where.
Is this how you set teh fition values?

Code: Select all
static void UserContactFriction (const NewtonJoint* contactJoint, dFloat timestep, int threadIndex)
{
   // call  the basic call back
   GenericContactProcess (contactJoint, timestep, threadIndex);


   dFloat frictionValue = friction->GetFloat();
   for (void* contact = NewtonContactJointGetFirstContact (contactJoint); contact; contact = NewtonContactJointGetNextContact (contactJoint, contact)) {
      NewtonMaterial* const material = NewtonContactGetMaterial (contact);
//      NewtonMaterialSetContactFrictionCoef (material, frictionValue + 0.1f, frictionValue, 0);
//      NewtonMaterialSetContactFrictionCoef (material, frictionValue + 0.1f, frictionValue, 1);
      NewtonMaterialSetContactFrictionCoef (material, 0.0f, 0.0f, 0);
      NewtonMaterialSetContactFrictionCoef (material, 0.0f, 0.0f, 1);
   }
}
I just did that in the friction test demo test demo and it works as it should, is that how you did it?


Let us do one thing at a time, first let us find out if the contact forces are coming as they are expected to be. here is the code to display the components of the friction force component at each contact.
Code: Select all
static void RenderBodyContactsForces (NewtonBody* const body, float scale)
{

   for (NewtonJoint* joint = NewtonBodyGetFirstContactJoint(body); joint; joint = NewtonBodyGetNextContactJoint(body, joint)) {
      for (void* contact = NewtonContactJointGetFirstContact (joint); contact; contact = NewtonContactJointGetNextContact (joint, contact)) {
         dVector point;
         dVector normal;   
         dVector tangnetDir0;
         dVector tangnetDir1;
         dVector contactForce;   
         NewtonMaterial* const material = NewtonContactGetMaterial (contact);

         NewtonMaterialGetContactForce(material, body, &contactForce.m_x);
         NewtonMaterialGetContactPositionAndNormal (material, body, &point.m_x, &normal.m_x);
         NewtonMaterialGetContactTangentDirections(material, body, &tangnetDir0[0], &tangnetDir1[0]);

         // these are the components of the tangents forces at the contact point, the can be display at the contact position point.
         dVector tangentForce1 (tangnetDir0.Scale ((contactForce % tangnetDir0) * scale));
         dVector tangentForce2 (tangnetDir1.Scale ((contactForce % tangnetDir1) * scale));

            
//         glVertex3f (p0.m_x, p0.m_y, p0.m_z);
//         glVertex3f (p1.m_x, p1.m_y, p1.m_z);
      }
   }
}

use the and make a simple video, do no rennet the tangent normal, instead use this code to show the value of the friction forces, which is what count.
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Sliding Object Behavior

Postby michDS » Fri Aug 19, 2011 7:05 pm

Here's the video showing the friction forces using the code you provided:

http://digitalsmoke.us/ISUHD31_forces_3.mov

I set the friction values the same as you in the collision callback function:
Code: Select all
for (void* contact = NewtonContactJointGetFirstContact (pContactJoint); contact; contact = NewtonContactJointGetNextContact (pContactJoint, contact))
{
    NewtonMaterial* const material = NewtonContactGetMaterial (contact);
    NewtonMaterialSetContactFrictionCoef (material, 0.0f, 0.0f, 0);
    NewtonMaterialSetContactFrictionCoef (material, 0.0f, 0.0f, 1);
}


Things look correct if I only set the dynamic friction to 0.0f like this:
Code: Select all
for (void* contact = NewtonContactJointGetFirstContact (pContactJoint); contact; contact = NewtonContactJointGetNextContact (pContactJoint, contact))
{
    NewtonMaterial* const material = NewtonContactGetMaterial (contact);
    NewtonMaterialSetContactFrictionCoef (material, 0.5f, 0.0f, 0);
    NewtonMaterialSetContactFrictionCoef (material, 0.5f, 0.0f, 1);
}

http://digitalsmoke.us/ISUHD31_forces_2.mov

I did find a bug that I had when setting NewtonMaterialContactRotateTangentDirections. When I fixed it the puck does go straight (only if I don't set the static friction coefficient to 0.0f).
Here's a video without overriding any static or dynamic friction:

http://digitalsmoke.us/ISUHD31_forces_1.mov

I'm not sure why setting the friction coefficient to 0.0f causes the puck to not go straight. I also still can't get the puck to go straight in the other situation where it falls off the left edge of the table.

http://digitalsmoke.us/ISUHD31_forces_4.mov
Last edited by michDS on Fri Aug 19, 2011 7:31 pm, edited 1 time in total.
michDS
 
Posts: 33
Joined: Fri Aug 12, 2011 3:47 pm

Re: Sliding Object Behavior

Postby michDS » Fri Aug 19, 2011 7:29 pm

FYI, my version of these functions doesn't have the body parameter:

Code: Select all
NEWTON_API void NewtonMaterialGetContactForce (const NewtonMaterial* material, dFloat* force);
NEWTON_API void NewtonMaterialGetContactPositionAndNormal (const NewtonMaterial* material, dFloat* posit, dFloat* normal);
NEWTON_API void NewtonMaterialGetContactTangentDirections (const NewtonMaterial* material, dFloat* dir0, dFloat* dir1);

I'm using newton-dynamics-2.33.rar, so I'm not sure why we have those differences.
michDS
 
Posts: 33
Joined: Fri Aug 12, 2011 3:47 pm

Re: Sliding Object Behavior

Postby Julio Jerez » Fri Aug 19, 2011 11:39 pm

Ok something somewhere is very, very wrong.
Let us clarify what the line means.

I see Green lines and Red lines, but it looks to me that the Red Lines are Normal forces. are you drawing the normal force?
The two tangent forces at least should be tangent to the floor, make sure that debug code is correct.

The secund part is that I can see how the forces jump from zero when is correct to some bug no zero value when the puck go over some area, that's the Bug.
But first let us make sure the debug code that draw the tangent forces are correct, those values should be horizontal as long as the Puck is on top of the Ramp.
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Sliding Object Behavior

Postby michDS » Sat Aug 20, 2011 3:43 pm

Darn, sorry about that. Here's the corrected video:

http://www.digitalsmoke.us/ISUHD31_forces.mov

Red = primary tangent force
Green = secondary tangent force
michDS
 
Posts: 33
Joined: Fri Aug 12, 2011 3:47 pm

Re: Sliding Object Behavior

Postby Julio Jerez » Sat Aug 20, 2011 6:44 pm

Tell me something is the read tangent to the floor or it is me seen a perpective optical illution?

also I see that teh green are diffrnt than zero whn eh puck it hittin the edge.
that is the real reason why the puck move away form the edge.
some how the friction value you are setting are not taking place and the sideway force are not zero.

are you sure you are setting the dynamics and static friction coeficient on the secund tangent to zero?
if you are then maybe there ther is a bug in teh engine that is no allwoen teh fition value to be zero.
can I test this on a PC? or is this and Iphone only project, if it is a Mac how can I test it?

The forces reaction looks very good, execpt fo that but that is not obeying the friction values override.
once that problem is taken care all the wirdness should go away.

One think you should do, and I kknow this will delay you for two or three days correcting syntact erros, is that you should get the latest version from SVN.
there are bug fixes, and if I am going to test this you should be in the latest version. the fixes are minor but important and soem have iterface changes specially on the materail callbacks.
whic now tak ethe body for wich the user quiere the information.
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Sliding Object Behavior

Postby michDS » Sun Aug 21, 2011 3:02 am

The red tangent is parallel to the table, so you're seeing it as an optical illusion (I have the depth buffer enabled, so if it was going into the table, it wouldn't be visible).

I'm pretty sure I'm setting the friction coefficient correctly:
Code: Select all
      for (void* contact = NewtonContactJointGetFirstContact (pContactJoint); contact; contact = NewtonContactJointGetNextContact (pContactJoint, contact))
      {
         NewtonMaterial* const material = NewtonContactGetMaterial (contact);
         NewtonMaterialSetContactFrictionCoef (material, 0.0f, 0.0f, 0);
         NewtonMaterialSetContactFrictionCoef (material, 0.0f, 0.0f, 1);
      }

This is an iPhone only project but you can test it on the Mac using Xcode and iPhone simulator (downloadable for free). Let me know if you would be able to do that, and I'll get the latest version of Newton from SVN. Should I use coreLibrary_300 or coreLibrary_200?
michDS
 
Posts: 33
Joined: Fri Aug 12, 2011 3:47 pm

Re: Sliding Object Behavior

Postby Julio Jerez » Sun Aug 21, 2011 9:18 am

I can try test it on my mac but you need to get the lastest or coreLibrary_200 from SVN, since ther are differences.
then I cna test it out.
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Sliding Object Behavior

Postby michDS » Tue Aug 23, 2011 2:27 am

Hi Julio,

I have a project for you to test on the Mac. It uses the latest coreLibrary_200. Since the code is confidential, can I send you a PM of the source link?
michDS
 
Posts: 33
Joined: Fri Aug 12, 2011 3:47 pm

Re: Sliding Object Behavior

Postby Julio Jerez » Tue Aug 23, 2011 8:42 am

send me a PM wit teh link, I will test it this weekeng
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Previous

Return to General Discussion

Who is online

Users browsing this forum: No registered users and 2 guests

cron