Joint constraint friction

Post Reply
User avatar
Dragonlord
Posts: 198
Joined: Mon Sep 04, 2006 5:31 pm
Location: Switzerland
Contact:

Joint constraint friction

Post by Dragonlord »

I'm trying to implement the simple concept of friction in constraints, for example a rusty door. The existing bullet constraints seem to be friction-less and do not seem to expose anything related to this. Now I'm trying to figure out how friction in joint constraints would have to be added ontop of bullet.

I see two possible solutions:

1) Apply corrective impulses before solving constraints. This would reduce the force before constraints start to kick in. On the other hand it is applied only before the solving not taking part in the actually solving equations

2) Apply corrective impulses during getInfo2 phase similar to angular motors. This seems to me to be the more correct solution but I'm having troubles to understand how this would actually work. Angular motors seem to be a solution but they exist only in generic 6dof constraints and are static forces applied.

Any idea how this could be achieved?
Flix
Posts: 456
Joined: Tue Dec 25, 2007 1:06 pm

Re: Joint constraint friction

Post by Flix »

I don't know if this is appropriate or not, but there's an old thread about something similiar that could be helpful: http://www.bulletphysics.org/Bullet/php ... otor+force.
Basroil
Posts: 463
Joined: Fri Nov 30, 2012 4:50 am

Re: Joint constraint friction

Post by Basroil »

It depends on what type of joints you mean. If you mean friction with no additional force (i.e. door hinge) it's easy, but friction+motor force is difficult (revolving door with built in motor).
User avatar
Dragonlord
Posts: 198
Joined: Mon Sep 04, 2006 5:31 pm
Location: Switzerland
Contact:

Re: Joint constraint friction

Post by Dragonlord »

In this case just inner friction of a joint. I've looked at the topic but it uses motors and only 6dof has motors as far as I get it.
Basroil
Posts: 463
Joined: Fri Nov 30, 2012 4:50 am

Re: Joint constraint friction

Post by Basroil »

Dragonlord wrote:In this case just inner friction of a joint. I've looked at the topic but it uses motors and only 6dof has motors as far as I get it.
btHingeConstraint and Hinge2Constraint also have them, just use enableAngularMotor with 0 target velocity and max torque being equal to max friction
User avatar
Dragonlord
Posts: 198
Joined: Mon Sep 04, 2006 5:31 pm
Location: Switzerland
Contact:

Re: Joint constraint friction

Post by Dragonlord »

Basroil wrote:
Dragonlord wrote:In this case just inner friction of a joint. I've looked at the topic but it uses motors and only 6dof has motors as far as I get it.
btHingeConstraint and Hinge2Constraint also have them, just use enableAngularMotor with 0 target velocity and max torque being equal to max friction
What exactly is the meaning of the max torque? Is it like target velocity?
Basroil
Posts: 463
Joined: Fri Nov 30, 2012 4:50 am

Re: Joint constraint friction

Post by Basroil »

Dragonlord wrote: What exactly is the meaning of the max torque? Is it like target velocity?
Constraints are basically optimization problems where you seek the minimum force needed to keep a desired velocity. If you can hit 0 velocity with less than your maximum friction force, it'll use less force than the max, but you can't use more than that number.
User avatar
Dragonlord
Posts: 198
Joined: Mon Sep 04, 2006 5:31 pm
Location: Switzerland
Contact:

Re: Joint constraint friction

Post by Dragonlord »

Basroil wrote:
Dragonlord wrote: What exactly is the meaning of the max torque? Is it like target velocity?
Constraints are basically optimization problems where you seek the minimum force needed to keep a desired velocity. If you can hit 0 velocity with less than your maximum friction force, it'll use less force than the max, but you can't use more than that number.
Then I assume the quantity qualifier is the same for max torque and m_friction although the names are suggessting totally something else? Does this mean max torque should equal m_friction? Naming in bullet is really confusing at times.
Basroil
Posts: 463
Joined: Fri Nov 30, 2012 4:50 am

Re: Joint constraint friction

Post by Basroil »

Dragonlord wrote:
Basroil wrote:
Dragonlord wrote: What exactly is the meaning of the max torque? Is it like target velocity?
Constraints are basically optimization problems where you seek the minimum force needed to keep a desired velocity. If you can hit 0 velocity with less than your maximum friction force, it'll use less force than the max, but you can't use more than that number.
Then I assume the quantity qualifier is the same for max torque and m_friction although the names are suggessting totally something else? Does this mean max torque should equal m_friction? Naming in bullet is really confusing at times.
sounds like you are confusing demo file variables with api ones, since 6dof constraint does not include any variables called m_friction
User avatar
Dragonlord
Posts: 198
Joined: Mon Sep 04, 2006 5:31 pm
Location: Switzerland
Contact:

Re: Joint constraint friction

Post by Dragonlord »

What I find in the source is this:

Code: Select all

btScalar mot_fact = getMotorFactor(	limot->m_currentPosition, limot->m_loLimit, limot->m_hiLimit, tag_vel, info->fps * limot->m_stopERP);
info->m_constraintError[srow] += mot_fact * limot->m_targetVelocity;
info->m_lowerLimit[srow] = -limot->m_maxMotorForce;
info->m_upperLimit[srow] = limot->m_maxMotorForce;
I assume with max torque you refer to m_maxMotorForce? m_lowerLimit and m_upperLimit are though used as impulse quantities in the sequential solver class for which i'm not not sure if that is actually correct (or again improper variable naming)?
Basroil
Posts: 463
Joined: Fri Nov 30, 2012 4:50 am

Re: Joint constraint friction

Post by Basroil »

Dragonlord wrote:What I find in the source is this:

Code: Select all

btScalar mot_fact = getMotorFactor(	limot->m_currentPosition, limot->m_loLimit, limot->m_hiLimit, tag_vel, info->fps * limot->m_stopERP);
info->m_constraintError[srow] += mot_fact * limot->m_targetVelocity;
info->m_lowerLimit[srow] = -limot->m_maxMotorForce;
info->m_upperLimit[srow] = limot->m_maxMotorForce;
I assume with max torque you refer to m_maxMotorForce? m_lowerLimit and m_upperLimit are though used as impulse quantities in the sequential solver class for which i'm not not sure if that is actually correct (or again improper variable naming)?
That is exactly it, and yes, some of the naming is technically wrong for it's function, but it's easy enough to get used to it. Bullet works mainly in impulses, linear ones for velocity and angular ones for angular velocity, but since you move in discrete time intervals those are mathematical approximations of the actual force/torque.

basically you set the max motor force to what your motor or friction can use (in case of friction it'll can be some sort of function of velocity, like in ball bearings, for motors it's the motor strength) and then a target velocity (0 for just friction, a function of the error between your target angle and current angle for powered hinge/spring loaded hinge)
User avatar
Dragonlord
Posts: 198
Joined: Mon Sep 04, 2006 5:31 pm
Location: Switzerland
Contact:

Re: Joint constraint friction

Post by Dragonlord »

Basroil wrote:
Dragonlord wrote:What I find in the source is this:

Code: Select all

btScalar mot_fact = getMotorFactor(	limot->m_currentPosition, limot->m_loLimit, limot->m_hiLimit, tag_vel, info->fps * limot->m_stopERP);
info->m_constraintError[srow] += mot_fact * limot->m_targetVelocity;
info->m_lowerLimit[srow] = -limot->m_maxMotorForce;
info->m_upperLimit[srow] = limot->m_maxMotorForce;
I assume with max torque you refer to m_maxMotorForce? m_lowerLimit and m_upperLimit are though used as impulse quantities in the sequential solver class for which i'm not not sure if that is actually correct (or again improper variable naming)?
That is exactly it, and yes, some of the naming is technically wrong for it's function, but it's easy enough to get used to it. Bullet works mainly in impulses, linear ones for velocity and angular ones for angular velocity, but since you move in discrete time intervals those are mathematical approximations of the actual force/torque.

basically you set the max motor force to what your motor or friction can use (in case of friction it'll can be some sort of function of velocity, like in ball bearings, for motors it's the motor strength) and then a target velocity (0 for just friction, a function of the error between your target angle and current angle for powered hinge/spring loaded hinge)
I get the basic idea but I'm still a bit at a loss about the details. You said "what your motor or friction can use". What does it "use"? You said it's a function of velocity so I assume with "use" you mean mass*|velocityInAxis|*jointFriction ? This would be the absolute friction impuls. The m_stopERP though should this be 1 in this case?
Post Reply