porting from bullet 2.71 to 2.74: Friction Callback gone
-
- Posts: 11
- Joined: Tue Sep 16, 2008 9:34 am
porting from bullet 2.71 to 2.74: Friction Callback gone
Hello,
I am currently trying to update some code I wrote for 2.71. It uses the old user defined friction callback in the btSequentialConstraintSolver (see appCcdPhysicsDemo: #define USER_DEFINED_FRICTION_MODEL 1).
I realize the solvers function SetFrictionSolverFunc() is gone. Will it still be possible to manipulate the friction function? If yes, how? If no, how can one implement special friction models?
Thanks in Advance,
Georg.
I am currently trying to update some code I wrote for 2.71. It uses the old user defined friction callback in the btSequentialConstraintSolver (see appCcdPhysicsDemo: #define USER_DEFINED_FRICTION_MODEL 1).
I realize the solvers function SetFrictionSolverFunc() is gone. Will it still be possible to manipulate the friction function? If yes, how? If no, how can one implement special friction models?
Thanks in Advance,
Georg.
-
- Site Admin
- Posts: 4221
- Joined: Sun Jun 26, 2005 6:43 pm
- Location: California, USA
Re: porting from bullet 2.71 to 2.74: Friction Callback gone
The current constraint solver doesn't have a few older features, that were difficult to combine with certain optimizations.
In a future version, we might add a slower-but-more-extensible constraint solver, that suits your need. We can add split-impulse to that too.
Thanks,
Erwin
In a future version, we might add a slower-but-more-extensible constraint solver, that suits your need. We can add split-impulse to that too.
Thanks,
Erwin
-
- Posts: 26
- Joined: Wed Feb 27, 2008 9:55 am
Re: porting from bullet 2.71 to 2.74: Friction Callback gone
We were using this to simulate conveyor belts - the Friction callback would calculate the friction using overridden velocities when solving for the conveyor belt.
The solver has changed so much I can't see how to do this anymore..
Are there any known ways to get around this in the new system? Any alternative callbacks I can still use?
The solver has changed so much I can't see how to do this anymore..
Are there any known ways to get around this in the new system? Any alternative callbacks I can still use?
-
- Posts: 11
- Joined: Tue Sep 16, 2008 9:34 am
Re: porting from bullet 2.71 to 2.74: Friction Callback gone
Hi Erwin,
thank you for your immediate answer, I havent had a look for a while. Has anything been done to reactive the friction callback? I remember to have traced it deep into the solver and having found a part where to add the velocity offset Bbilz was talking about.
Would modifications of the optimized solver be of interest? I would propose something like:
class btRigidBody
{
virtual const btVector3& getSurfaceVelocity() const { return btVector::zero; };
}
class btRigidBodyWithSurfaceVelocity: public btRigidbody
{
virtual const btVector3& getSurfaceVelocity() const { return surfaceVelocity; } ;
};
will do it for planar conveyors.
which coult implement a virtual surface velocity callback. If virtual calls are impossible or not wanted within the solving algorithms, one coudl just add a velocity to the rigidbody itself.
Please let me know if something alike is wanted then I will give it a try and propose a solution.
Cheers Georg.
thank you for your immediate answer, I havent had a look for a while. Has anything been done to reactive the friction callback? I remember to have traced it deep into the solver and having found a part where to add the velocity offset Bbilz was talking about.
Would modifications of the optimized solver be of interest? I would propose something like:
class btRigidBody
{
virtual const btVector3& getSurfaceVelocity() const { return btVector::zero; };
}
class btRigidBodyWithSurfaceVelocity: public btRigidbody
{
virtual const btVector3& getSurfaceVelocity() const { return surfaceVelocity; } ;
};
will do it for planar conveyors.
which coult implement a virtual surface velocity callback. If virtual calls are impossible or not wanted within the solving algorithms, one coudl just add a velocity to the rigidbody itself.
Please let me know if something alike is wanted then I will give it a try and propose a solution.
Cheers Georg.
-
- Posts: 96
- Joined: Mon Nov 03, 2008 9:57 pm
Re: porting from bullet 2.71 to 2.74: Friction Callback gone
BTW, "Custom Friction Model" is still mentioned in the user manual, although as reported here, the SetFrictionSolverFunc() that CcdPhysicsDemo (referenced from the manual) depended on has been removed. Might be nice to take a second and remove the outdated code from the demo and give a little documentation in the manual how to modify the friction parameters in Bullet. Thanks!
-
- Posts: 26
- Joined: Wed Feb 27, 2008 9:55 am
Re: porting from bullet 2.71 to 2.74: Friction Callback gone
Any more word on this?
We really need a way of overriding surface velocity (for the above mentioned conveyor belts) - or could someone point me to the right section of code to hack myself in a temporary solution..
Cheers!
We really need a way of overriding surface velocity (for the above mentioned conveyor belts) - or could someone point me to the right section of code to hack myself in a temporary solution..
Cheers!
-
- Posts: 96
- Joined: Mon Nov 03, 2008 9:57 pm
Re: porting from bullet 2.71 to 2.74: Friction Callback gone
I was going to say, I wonder if you could add a hook before each timestep set the velocity of your conveyor belt and reset its position back to the starting position, but I think the contacts of objects sitting on the belt might get confused.
Which leads to a better suggestion, if you hook into the belt contacts and move the relative position of each belt contact point on each timestep, shouldn't that provide the same effect as if the belt surface was actually moving?
You might also consider building the belt out of several pieces, let the pieces actually move over time, and teleport them from one end to the other as they go past the end of the belt.
Which leads to a better suggestion, if you hook into the belt contacts and move the relative position of each belt contact point on each timestep, shouldn't that provide the same effect as if the belt surface was actually moving?
You might also consider building the belt out of several pieces, let the pieces actually move over time, and teleport them from one end to the other as they go past the end of the belt.
-
- Posts: 11
- Joined: Tue Sep 16, 2008 9:34 am
Re: porting from bullet 2.71 to 2.74: Friction Callback gone
Hi,
we have also thought about the solution with moving bodies, changing their size etc. but this ends up in a bad hack with low performance on a large number of conveyors, simulation artefacts.
Within the friction solver somewhere the relative surface velocity of the contact points needs to be calculated for each contact point. If you just add a velocity vector stored with the conveyor body at this point, everything is calculated physically correctly, no artefacts, future friction models apply etc..
I agree with Bbilz's post as we definitely need that surface velocity.
Cheers
we have also thought about the solution with moving bodies, changing their size etc. but this ends up in a bad hack with low performance on a large number of conveyors, simulation artefacts.
Within the friction solver somewhere the relative surface velocity of the contact points needs to be calculated for each contact point. If you just add a velocity vector stored with the conveyor body at this point, everything is calculated physically correctly, no artefacts, future friction models apply etc..
I agree with Bbilz's post as we definitely need that surface velocity.
Cheers
-
- Site Admin
- Posts: 4221
- Joined: Sun Jun 26, 2005 6:43 pm
- Location: California, USA
Re: porting from bullet 2.71 to 2.74: Friction Callback gone
Latest trunk let's you specify custom friction directions, as well as target motion/velocity in both directions, and slip/cfm.
This can be used for a conveyor belt effect etc.
In a nutshell, you setup a contact added callback, enable the callback for selected bodies, and enable this solver flag.
See attached modified BasicDemo.cpp for an example.
Hope this helps,
Erwin
This can be used for a conveyor belt effect etc.
In a nutshell, you setup a contact added callback, enable the callback for selected bodies, and enable this solver flag.
Code: Select all
gContactAddedCallback = CustomMaterialCombinerCallback;
///this flag will use the friction information from the contact point, if contactPoint.m_lateralFrictionInitialized==true
m_dynamicsWorld->getSolverInfo().m_solverMode |= SOLVER_ENABLE_FRICTION_DIRECTION_CACHING;
///enable the callback for the ground object
body->setCollisionFlags(body->getCollisionFlags() | btCollisionObject::CF_CUSTOM_MATERIAL_CALLBACK);
///set the friction during the contact added callback, for selected bodies
static bool CustomMaterialCombinerCallback(btManifoldPoint& cp, const btCollisionObject* colObj0,int partId0,int index0,const btCollisionObject* colObj1,int partId1,int index1)
{
cp.m_lateralFrictionInitialized = true;
cp.m_lateralFrictionDir1.setValue(1,0,0);
///downscale the friction direction 2 for lower (anisotropic) friction (rather than a unit vector)
cp.m_lateralFrictionDir2.setValue(0,0,0.1);
///choose a target surface velocity in the friction dir1 direction, for a conveyor belt effect
cp.m_contactMotion1 = 1.f;
//cp.m_contactMotion1 = 1.f;
//cp.m_contactCFM2 = 0.1;
//cp.m_combinedFriction = 10;
//cp.m_combinedRestitution = calculateCombinedRestitution(restitution0,restitution1);
return true;
}
Hope this helps,
Erwin
You do not have the required permissions to view the files attached to this post.
-
- Posts: 11
- Joined: Tue Sep 16, 2008 9:34 am
Re: porting from bullet 2.71 to 2.74: Friction Callback gone
Great Erwin,
thank you.
thank you.
-
- Posts: 11
- Joined: Tue Sep 16, 2008 9:34 am
Re: porting from bullet 2.71 to 2.74: Friction Callback gone
Dear bullet users,
I had a closer look into the friction callback and some questions as I havent got the clue:
The aim is to yield a conveyor on which the objects behave just as on a normal surface with friction. Imagine a moving rubber band or something of that kind where the boxes are sliding on and coming to a "stop" following the motion of the conveyor.
could you please explain the meaning of the following parameters:
bool m_lateralFrictionInitialized; // I understand this enables directed friction
btScalar m_appliedImpulseLateral1; // what are the indices 1 and 2?
btScalar m_appliedImpulseLateral2;
btScalar m_contactMotion1;// what are the indices 1 and 2?
btScalar m_contactMotion2;
btScalar m_contactCFM1; // what stands CFM for?
btScalar m_contactCFM2; // what are the indices 1 and 2?
btVector3 m_lateralFrictionDir1;// what are the indices 1 and 2?
btVector3 m_lateralFrictionDir2;
Do I have to compute and set those parameters? Are some precomputed for the normal friction case such that I only need to add the velocity of the conveyor?
Please help, Secondwish.
I had a closer look into the friction callback and some questions as I havent got the clue:
The aim is to yield a conveyor on which the objects behave just as on a normal surface with friction. Imagine a moving rubber band or something of that kind where the boxes are sliding on and coming to a "stop" following the motion of the conveyor.
could you please explain the meaning of the following parameters:
bool m_lateralFrictionInitialized; // I understand this enables directed friction
btScalar m_appliedImpulseLateral1; // what are the indices 1 and 2?
btScalar m_appliedImpulseLateral2;
btScalar m_contactMotion1;// what are the indices 1 and 2?
btScalar m_contactMotion2;
btScalar m_contactCFM1; // what stands CFM for?
btScalar m_contactCFM2; // what are the indices 1 and 2?
btVector3 m_lateralFrictionDir1;// what are the indices 1 and 2?
btVector3 m_lateralFrictionDir2;
Do I have to compute and set those parameters? Are some precomputed for the normal friction case such that I only need to add the velocity of the conveyor?
Please help, Secondwish.
-
- Posts: 2
- Joined: Sat Oct 10, 2009 7:35 am
Re: porting from bullet 2.71 to 2.74: Friction Callback gone
Hi, I think the "m_contactMotion1" member is gone in class "btManifoldPoint" for bullet 2.75.
Compiling failed.
Is this abandoned? If yes, it would be a pity since I really need a way to set surface velocity to simulate moving conveyor...
Compiling failed.
Is this abandoned? If yes, it would be a pity since I really need a way to set surface velocity to simulate moving conveyor...
Erwin Coumans wrote:ErwinCode: Select all
gContactAddedCallback = CustomMaterialCombinerCallback; ///this flag will use the friction information from the contact point, if contactPoint.m_lateralFrictionInitialized==true m_dynamicsWorld->getSolverInfo().m_solverMode |= SOLVER_ENABLE_FRICTION_DIRECTION_CACHING; ///enable the callback for the ground object body->setCollisionFlags(body->getCollisionFlags() | btCollisionObject::CF_CUSTOM_MATERIAL_CALLBACK); ///set the friction during the contact added callback, for selected bodies static bool CustomMaterialCombinerCallback(btManifoldPoint& cp, const btCollisionObject* colObj0,int partId0,int index0,const btCollisionObject* colObj1,int partId1,int index1) { cp.m_lateralFrictionInitialized = true; cp.m_lateralFrictionDir1.setValue(1,0,0); ///downscale the friction direction 2 for lower (anisotropic) friction (rather than a unit vector) cp.m_lateralFrictionDir2.setValue(0,0,0.1); ///choose a target surface velocity in the friction dir1 direction, for a conveyor belt effect cp.m_contactMotion1 = 1.f; //cp.m_contactMotion1 = 1.f; //cp.m_contactCFM2 = 0.1; //cp.m_combinedFriction = 10; //cp.m_combinedRestitution = calculateCombinedRestitution(restitution0,restitution1); return true; }
-
- Posts: 4
- Joined: Wed Dec 02, 2009 6:43 pm
Re: porting from bullet 2.71 to 2.74: Friction Callback gone
Any word on this?
With the contact motion variable gone, is it still possible to override contact velocity?
Thanks!
-David
With the contact motion variable gone, is it still possible to override contact velocity?
Thanks!
-David
-
- Site Admin
- Posts: 4221
- Joined: Sun Jun 26, 2005 6:43 pm
- Location: California, USA
Re: porting from bullet 2.71 to 2.74: Friction Callback gone
This friction/contact motion support has been added after the Bullet 2.75 release. So you have to use the latest trunk or wait for Bullet 2.76.HelloDavid wrote:Any word on this?
With the contact motion variable gone, is it still possible to override contact velocity?
Thanks!
-David
There is a convenient bullet-trunk-r1845.zip in the download section.
Cheers,
Erwin
-
- Posts: 4
- Joined: Wed Dec 02, 2009 6:43 pm
Re: porting from bullet 2.71 to 2.74: Friction Callback gone
Of course! I should have realised that sorry
Works a charm, thanks!
-David
Works a charm, thanks!
-David