Physics Simulation Forum

 

All times are UTC




Post new topic Reply to topic  [ 2 posts ] 
Author Message
PostPosted: Fri Mar 09, 2012 5:00 am 
Offline

Joined: Wed Feb 01, 2012 5:37 am
Posts: 5
Hi!

I had trouble with the friction. Previously, I could not get the lateral values (post: http://bulletphysics.org/Bullet/phpBB3/viewtopic.php?f=9&t=7906)

Examining through btSequentialImpulseConstraintSolver, I understood how to update
friction values. It's interesting to learn how these variables work.


Now I can get the friction force, but still, I cannot understand regarding it's order.

When you look down into adding friction constraint sequence in btSequentialImpulseConstraintSolver, you can see that m_lateralFrictionDir2 is added prior to m_lateralFrictionDir1. With this order, after in resolve sequences, m_appliedImpulseLateral1 is set by the value which was computed from m_lateralFrictionDir2. It means, if you want to use friction direction and magnitude from outside, you should use m_lateralFrictionDir1 with m_appliedImpulseLateral2, and vice versa.

It was quite confusing, and I took a look through the functions of btSequentialImpulseConstraintSolver to verify the problem. I'm not sure if that is intended or not, but if it needs to be fixed, then just changing addition code should be enough.

for example, inside convertContact:
Code:
if (!(infoGlobal.m_solverMode & SOLVER_DISABLE_VELOCITY_DEPENDENT_FRICTION_DIRECTION) && lat_rel_vel > SIMD_EPSILON)
            {
               cp.m_lateralFrictionDir1 /= btSqrt(lat_rel_vel);
               if((infoGlobal.m_solverMode & SOLVER_USE_2_FRICTION_DIRECTIONS))
               {
                  cp.m_lateralFrictionDir2 = cp.m_lateralFrictionDir1.cross(cp.m_normalWorldOnB);
                  cp.m_lateralFrictionDir2.normalize();//??
                  applyAnisotropicFriction(colObj0,cp.m_lateralFrictionDir2);
                  applyAnisotropicFriction(colObj1,cp.m_lateralFrictionDir2);
                  addFrictionConstraint(cp.m_lateralFrictionDir2,solverBodyA,solverBodyB,frictionIndex,cp,rel_pos1,rel_pos2,colObj0,colObj1, relaxation);
               }

               applyAnisotropicFriction(colObj0,cp.m_lateralFrictionDir1);
               applyAnisotropicFriction(colObj1,cp.m_lateralFrictionDir1);
               addFrictionConstraint(cp.m_lateralFrictionDir1,solverBodyA,solverBodyB,frictionIndex,cp,rel_pos1,rel_pos2,colObj0,colObj1, relaxation);
               cp.m_lateralFrictionInitialized = true;
            }



after changing order of adding constraints:
Code:
if (!(infoGlobal.m_solverMode & SOLVER_DISABLE_VELOCITY_DEPENDENT_FRICTION_DIRECTION) && lat_rel_vel > SIMD_EPSILON)
            {
               cp.m_lateralFrictionDir1 /= btSqrt(lat_rel_vel);

               applyAnisotropicFriction(colObj0,cp.m_lateralFrictionDir1);
               applyAnisotropicFriction(colObj1,cp.m_lateralFrictionDir1);
               addFrictionConstraint(cp.m_lateralFrictionDir1,solverBodyA,solverBodyB,frictionIndex,cp,rel_pos1,rel_pos2,colObj0,colObj1, relaxation);

               if((infoGlobal.m_solverMode & SOLVER_USE_2_FRICTION_DIRECTIONS))
               {
                  cp.m_lateralFrictionDir2 = cp.m_lateralFrictionDir1.cross(cp.m_normalWorldOnB);
                  cp.m_lateralFrictionDir2.normalize();//??
                  applyAnisotropicFriction(colObj0,cp.m_lateralFrictionDir2);
                  applyAnisotropicFriction(colObj1,cp.m_lateralFrictionDir2);
                  addFrictionConstraint(cp.m_lateralFrictionDir2,solverBodyA,solverBodyB,frictionIndex,cp,rel_pos1,rel_pos2,colObj0,colObj1, relaxation);
               }

               cp.m_lateralFrictionInitialized = true;
            }


Top
 Profile  
 
PostPosted: Mon Apr 23, 2012 3:20 pm 
Offline

Joined: Mon Apr 23, 2012 2:57 pm
Posts: 2
Hi,

I had similar problems like you had. First I was not able to get the lateral components of the contact impulses. First I applied the solver flags and the values are updated now.

But even if I follow your advise concerning the changes in the code of Bullet, I can't manage to get proper results for the friction force applied to the body. I inserted a debug output for the values of m_appliedLateralImpulse1 and m_appliedLateralImpulse2 but these values change all the time as if they are integrated or they accumulate some values. In my example (10° inclined plane and a body on it) the value for m_appliedLateralImpulse1 change from 0.20 to -0.20 over a period of approximately 30 seconds and than keep that value. I did some analysis of the btSequentialImpulseConstraintSolver.cpp without finding something that helped.

Did you manged to get proper values for friction force? Or did anyone ever?

Regards,
anyway


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC


Who is online

Users browsing this forum: Google [Bot] and 4 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group