friction model

Post Reply
bishopnator
Posts: 3
Joined: Sat Sep 13, 2008 8:40 am

friction model

Post by bishopnator » Sat Sep 13, 2008 8:53 am

Hi, I am new with using bullet. I need simple simulation in my game - pyramid with cylinders which can be hit with flying ball. First I create simple plane a put 1 cylinder on it and it rolls infinitly - like without friction. I looked in your examples (ie. CcdPhysicsDemo) and I see same behaviour.

I tried following possibilities (all works same - no friction) (for all options I use friction set to 0.5)
1. setup same friction to all rigid bodies
2. setup collision flag CF_CUSTOM_MATERIAL_CALLBACK to all my bodies and implement customMaterialCombinerCallback which only set friction (0.5) and restitution (0.1)
3. overwrite btDiscreteDynamicsWorld::getSolverInfo().m_solverMode &= ~SOLVER_CACHE_FRIENDLY

Without success :-\ Is in bullet some material / friction model? I didn't find any settings for static / kinetic friction / sliding / rolling friction, etc. I only found that it is possible to set friction / restitution to rigid body. When I set friction 0.0f to my cylinder, it only slides (which is correct ofcourse), but arbitrary greater value than 0.0f only cause that cylinder rolls along my plane. I also tried set greater damping linear velocity - cylinder slows down, but it is not friction.

For now I have in my game only static objects and one dynamic object - ball. I have my own physics implementation where I have static/kinetic friction, restitution in perpendicular direction on contact plane and restitution along contact plane. I need to add some dynamic objects and I am finding physics SDK which will suit my needs.

Nathanael
Posts: 78
Joined: Mon Nov 13, 2006 1:44 am

Re: friction model

Post by Nathanael » Sat Sep 13, 2008 10:03 am

Part of the problem may come from the fact that when only one contact is created between your cylinder and the plane, nothing prevent/damp angular velocities about the contact normal (contacts are points, not surfaces). Try adding a bit of angular damping along that axis, that should work.

Hope it help,
Nathanael.

bishopnator
Posts: 3
Joined: Sat Sep 13, 2008 8:40 am

Re: friction model

Post by bishopnator » Sat Sep 13, 2008 12:27 pm

Thanks for reply, but adding damping is horrible solution, it is not friction. Set some damping make whole system more stable - it's good. I need something like this: I have cylinder rolling along plane, with starting velocity 5m/s. I need, that this cylinder should stop at 10m far from beginning position (+/- 0.10m). In this case friction must be 0.125f. But it didn't work. Maybe some tutorials will be useful for that - I didn't find useful informations in bullet's documentation nor in bullet's examples.

I know, that cylinder will go further than cube from same material, because cube will slide along plane and cylinder will roll - but that's physics. I need to setup correct frictions, but I don't know where and how.

I tried 3 different physics engines - PhysX, Newton Dynamics and bullet. In PhysX I didn't find support for cylinders, Newton Dynamics is unstable for making pyramid from cylinders - my pyramid fell down after running application but there is very good material model. In bullet, my pyramid is stable, but it seems, that friction model is not working. I didn't find similar maetrial model in bullet. If it is planned to do later, it's not problem. I just asked, if there is support in current bullet's release or if it is possible to make something like material model.

I suppose that ContactAddedCallback is responsible to calculate correct friction and restitution if collision occurs between to objects (I need only rigid bodies). I setup there m_combinedFriction and m_combinedRestitution, but it don't work. I don't know what I am doing wrong (if it could work).

Nathanael
Posts: 78
Joined: Mon Nov 13, 2006 1:44 am

Re: friction model

Post by Nathanael » Sat Sep 13, 2008 1:19 pm

What you have is an infinitely rigid cylinder rolling over an infinitely rigid plane, no amount of 'classic' friction will ever stop the cylinder motion.
Most real life objects deform slightly on contact, and provide some non-zero area contact surface, they lose some energy when regaining their original shape, that's where the kind of friction you expect come from, but most physics engine doesn't model this because its effect is usually approximated well enough by angular damping (on contact).

here's a link that describe/explain the rolling cylinder case:
http://www.engineersedge.com/lubricatio ... iction.htm

Nathanael.

bishopnator
Posts: 3
Joined: Sat Sep 13, 2008 8:40 am

Re: friction model

Post by bishopnator » Tue Sep 16, 2008 7:27 am

it's sound logical, but it is hard to use, when I need different frictions (different materials). It is possible to set different damping when collision is detected? I looked in btRigidBody.cpp and I found, that applyDamping method is called every frame and velocity (both linear and angular) is descreasing with following equation: v' = v * (1 - K*dt), where v' is next velocity, v is current velocity, dt is frame time and K is damping constant. I integrate this equation and I get: v = v0 * exp(-K*t), where v0 is velocity at time 0s. So using this equation, rolling cylinder never stop. I suppose that it is possible to setup some velocity treshold, but I am confused about it - documentation is very poor about it. In btRigidBodyConstructionInfo I found m_linearSleepingThreshold and m_angularSleepingThreshold. There is no comment, so I'm not sure about using these settings.

ok, back to problem - I rather prefer linear velocity decreasing (more realistic when friction is applied .. I think ..), but also this damping model is acceptable for me. I tried to set different damping values and I didn't achieve desirable result. I get only to cases - either cylinder rolls infinitely or cylinder stops in few meters and it starts jittering (I am using btMotionState for synchronizing state between graphics and bullet).

I am really new in bullet, so if on web there is some detailed description about these problems (friction model / materials, etc.), it'll be very useful for me. I don't like studying tons of source codes, when I need just to use 3P library.

Post Reply