Friction problem - Sphere isnt rolling on a straight line.

Post Reply
rney
Posts: 4
Joined: Tue Mar 31, 2015 7:34 pm

Friction problem - Sphere isnt rolling on a straight line.

Post by rney » Tue Mar 31, 2015 8:12 pm

Hello guys :)

I am kind of new using bullet and I am trying to create a 8 ball pool game with it.
It was pretty hard for me to find a good configuration for friction, gravity and etc.. that would look familiar to a pool game.
My selection was :

Code: Select all

// Global physics parameters
#define PHYS_GLOBAL_SCALE_FACTOR (10.0f)
#define PHYS_SCALED(x) ((x) * PHYS_GLOBAL_SCALE_FACTOR)

#define PHYS_CONTACT_BREAK_THRESH (PHYS_SCALED(0.02f) * 0.1f)
#define PHYS_GRAVITY_Y_AXIS_SI PHYS_SCALED(-9.8f)

// Balls
#define PHYS_BALL_MASS (0.170f)
#define PHYS_BALL_RADIUS PHYS_SCALED(0.029f)
#define PHYS_BALL_FRICTION (0.2f)
#define PHYS_BALL_ROLL_FRICTION (0.1f)
#define PHYS_BALL_RESTITUTION (0.9f)
#define PHYS_BALL_LIN_DAMPING (0.0f)
#define PHYS_BALL_ANG_DAMPING (0.8f)
#define PHYS_BALL_LIN_SLEEP_THRESH (0.1f)
#define PHYS_BALL_ANG_SLEEP_THRESH (0.1f)

// Table floor
#define PHYS_FLOOR_FRICTION (0.3f)
#define PHYS_FLOOR_ROLL_FRICTION (0.1f)
Everything was going pretty well, however, I found a problem that I cannot solve.
When I try to apply an impulse to the center of mass of a sphere, this ball does not describe a straight line as a path, instead of it, the ball describes a path thats looks more like a curve of an exponential function.

eg : ball_rb->applyCentralImpulse(btVector3(1.5f,0.0f, 0.5f));

Describes:
Image

Instead of :
Image

I am also attaching my modified version of "RollingFrictionDemo" (I just edited the RollingFrictionDemo.cpp) to show my problem. Run the main and the ball will move after 2 seconds.

Any solutions?

Kind Regards, Rodrigo Ney.
Attachments
BRollingFrictionDemo.zip
(119.82 KiB) Downloaded 96 times

rney
Posts: 4
Joined: Tue Mar 31, 2015 7:34 pm

Re: Friction problem - Sphere isnt rolling on a straight lin

Post by rney » Tue Mar 31, 2015 10:07 pm

I don't know if I am following the right track, but I'm trying to understand what m_solverMode (btContactSolverInfo) means to the friction.

Can someone explain what these constants mean?

SOLVER_RANDMIZE_ORDER = 1,
SOLVER_FRICTION_SEPARATE = 2,
SOLVER_USE_WARMSTARTING = 4,
SOLVER_USE_2_FRICTION_DIRECTIONS = 16,
SOLVER_ENABLE_FRICTION_DIRECTION_CACHING = 32,
SOLVER_DISABLE_VELOCITY_DEPENDENT_FRICTION_DIRECTION = 64,
SOLVER_CACHE_FRIENDLY = 128,
SOLVER_SIMD = 256,
SOLVER_INTERLEAVE_CONTACT_AND_FRICTION_CONSTRAINTS = 512,
SOLVER_ALLOW_ZERO_LENGTH_FRICTION_DIRECTIONS = 1024

rney
Posts: 4
Joined: Tue Mar 31, 2015 7:34 pm

Re: Friction problem - Sphere isnt rolling on a straight lin

Post by rney » Thu Apr 02, 2015 6:18 pm

Hello Guys!
I solved the problem using this flag :
btContactSolverInfo& info = _dynamicsWorld->getSolverInfo();
info.m_solverMode |= SOLVER_INTERLEAVE_CONTACT_AND_FRICTION_CONSTRAINTS;
But I had to change all my configurations about friction and damping to have the same feeling that I had before.
Can someone explain to me what exactly this flag does? I can't find this information on the wiki.

Many Thanks!

rney
Posts: 4
Joined: Tue Mar 31, 2015 7:34 pm

Re: Friction problem - Sphere isnt rolling on a straight lin

Post by rney » Wed Apr 08, 2015 11:06 pm

I didn't find documentation about SOLVER_INTERLEAVE_CONTACT_AND_FRICTION_CONSTRAINTS yet....
Can someone help?

irwantozn1
Posts: 1
Joined: Fri Mar 01, 2019 3:35 am

Re: Friction problem - Sphere isnt rolling on a straight line.

Post by irwantozn1 » Fri Mar 01, 2019 4:04 am

I have same problem on version 2.83, then I'm update to 2.88 but problem still exist. Then I try to add solver mode as you said

btContactSolverInfo& info = _dynamicsWorld->getSolverInfo();
info.m_solverMode |= SOLVER_INTERLEAVE_CONTACT_AND_FRICTION_CONSTRAINTS;

but this problem didn't fix, my ball still rolling on the ground on curved trajectory ...

User avatar
Erwin Coumans
Site Admin
Posts: 4189
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA
Contact:

Re: Friction problem - Sphere isnt rolling on a straight line.

Post by Erwin Coumans » Fri Mar 01, 2019 4:22 am

Rolling friction indeed has an issue. We need to use cone friction for rolling friction (as we do for lateral friction).
Will be fixed in a little while, see this issue: https://github.com/bulletphysics/bullet3/issues/2117

For now, disable rolling friction and manually apply some force (or use damping).

User avatar
Erwin Coumans
Site Admin
Posts: 4189
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA
Contact:

Re: Friction problem - Sphere isnt rolling on a straight line.

Post by Erwin Coumans » Mon Mar 04, 2019 1:15 am

OK, I got around implementing cone friction for rolling friction, so the two rolling friction directions are coupled and clamped against the friction cone together (instead of each rolling friction direction clamped against a friction pyramid).

https://github.com/bulletphysics/bullet3/pull/2138

steven
Posts: 62
Joined: Mon Nov 05, 2018 8:16 am
Location: China

Re: Friction problem - Sphere isnt rolling on a straight line.

Post by steven » Thu Mar 07, 2019 2:48 am

this is my understanding, hope it can help you.
1. "I have same problem on version 2.83, then I'm update to 2.88 but problem still exist."
--> if we set the SOLVER_INTERLEAVE_CONTACT_AND_FRICTION_CONSTRAINTS, the rollingfriction doesn't take effect on version 2.83, but it always is enabled on version 2.88. you can refer to the file btSequentialImpulseConstraintSolver.cpp.
2. "If the velocity's direction is 0° 45° 90° 135° 180° 225° 270° 315°, the trajectories will be straight, otherwise bend."
--> we create a coordinate system based on the normal axis by btPlaneSpace1(), and then project the angular velocity to these three axes, but we don't project the rolling friction torque to these axes, instead we use this same torque for all the axes. for this case, it also can explain why it can work well with these special directions, as only one direction the projection of the rolling friction torque has non-zero value.

User avatar
Erwin Coumans
Site Admin
Posts: 4189
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA
Contact:

Re: Friction problem - Sphere isnt rolling on a straight line.

Post by Erwin Coumans » Thu Mar 07, 2019 4:15 am

@Steven:

Rolling friction works fine now, as long as you use btMultiBody, since we clamp against an implicit cone now, not against a pyramid.
The fix is here: https://github.com/bulletphysics/bullet ... r.cpp#L116


The fix hasn't been applied for the btRigidBody case yet (we primarily use btMultiBody for our robotics and reinforcement learning research).
I'll apply the same fix for btRigidBody in btSequentialImpulseConstraintSolver.cpp soon.

Post Reply