hi,
i want to fix two bodies together with btGeneric6DofConstraint locking all axis, but it doesn't work well. i think maybe the constraint force of btGeneric6DofConstraint is not big enough, but how to set btGeneric6DofConstraint's constraint force.
the circle in the following picture is the place where i place btGeneric6DofConstraint.
how to set btGeneric6DofConstraint's constraint force
-
- Posts: 4
- Joined: Sat Oct 15, 2011 3:47 pm
-
- Posts: 168
- Joined: Tue Jan 04, 2011 11:47 pm
Re: how to set btGeneric6DofConstraint's constraint force
It seems that there is only one function related with what you ask for, and still not exactly the force
What do you mean by "It is not working well" ?
Code: Select all
btScalar getAppliedImpulse () const
getAppliedImpulse is an estimated total applied impulse. It can be used to play sound or to determine whether the constraint should break apart
-
- Posts: 57
- Joined: Tue Mar 16, 2010 1:42 am
Re: how to set btGeneric6DofConstraint's constraint force
Constraints are always somewhat elastic due to the way they are solved. With sufficient force applied they can violate the axis limits.
To lock two object together without using a compound, I have had some success with using two 6Dof constraints, one placed at the centre of each object. In pseudocode something like:
Or have them anchored at different points so that the two constraints are not co-linear. You have to almost think like a structural engineer.
---JvdL---
To lock two object together without using a compound, I have had some success with using two 6Dof constraints, one placed at the centre of each object. In pseudocode something like:
Code: Select all
btTransform frame21 = object2_transform.inverse() * object1_transform;
constraint1 = new btGeneric6DofConstraint(object1, object2, identity_matrix, frame21, true);
btTransform frame12 = object1_transform.inverse() * object2_transform;
constraint2 = new btGeneric6DofConstraint(object2, object1, identity_matrix, frame12, true);
---JvdL---
-
- Posts: 4
- Joined: Sat Oct 15, 2011 3:47 pm
Re: how to set btGeneric6DofConstraint's constraint force
I have fixed two bodies together with btGeneric6DofConstraint, but they could move apart with each other in a certain extent.Dr.Shepherd wrote: What do you mean by "It is not working well" ?
-
- Posts: 168
- Joined: Tue Jan 04, 2011 11:47 pm
Re: how to set btGeneric6DofConstraint's constraint force
This seems interesting, =)jarno wrote:Constraints are always somewhat elastic due to the way they are solved. With sufficient force applied they can violate the axis limits.
To lock two object together without using a compound, I have had some success with using two 6Dof constraints, one placed at the centre of each object. In pseudocode something like:
Or have them anchored at different points so that the two constraints are not co-linear. You have to almost think like a structural engineer.
---JvdL---
Related with my own experience, when I use a big force to pull the body parts of a ragdoll, even though they are connected by constraints, they will move apart from each other as long as the force exists. I suppose this is due to the same reason for this "Elastic" constraints.
-
- Posts: 4
- Joined: Sat Oct 15, 2011 3:47 pm
Re: how to set btGeneric6DofConstraint's constraint force
I have tried you advice. It works better than before, but not well enough.jarno wrote:Constraints are always somewhat elastic due to the way they are solved. With sufficient force applied they can violate the axis limits.
To lock two object together without using a compound, I have had some success with using two 6Dof constraints, one placed at the centre of each object. In pseudocode something like:Or have them anchored at different points so that the two constraints are not co-linear. You have to almost think like a structural engineer.Code: Select all
btTransform frame21 = object2_transform.inverse() * object1_transform; constraint1 = new btGeneric6DofConstraint(object1, object2, identity_matrix, frame21, true); btTransform frame12 = object1_transform.inverse() * object2_transform; constraint2 = new btGeneric6DofConstraint(object2, object1, identity_matrix, frame12, true);
---JvdL---
It seems I have to use compound now.
-
- Posts: 50
- Joined: Fri Oct 29, 2010 1:37 am
Re: how to set btGeneric6DofConstraint's constraint force
Try pumping up the Constraint solver number of iterations, this helps alot with keeping constraints tighter, but at a frame rate cost. I think the default iteration number is a little on the low side imo. Its set to 10 currently, I run 30 right now...
pDynamicsWorld->getSolverInfo().m_numIterations = 30;
pDynamicsWorld->getSolverInfo().m_numIterations = 30;
-
- Posts: 52
- Joined: Wed Sep 28, 2011 8:36 am
- Location: France
Re: how to set btGeneric6DofConstraint's constraint force
You can change the "force" that bullet can use to correct the error on a constraint.
There are 2 parameters for that, called error reduction parameter (ERP) and constraint force mixing (CFM).
If you want to get more information on each, here is an article that explains it quite well (sorry, it's on the ODE wiki, but that's the only place where I could find it): http://opende.sourceforge.net/wiki/inde ... oncepts%29
But in short:
If CFM is set to zero, the constraint will be hard.
If CFM is set to a positive value, it will be possible to violate the constraint by "pushing on it"
(for example, for contact constraints by forcing the two contacting objects together).
In other words the constraint will be soft, and the softness will increase as CFM increases.
What is actually happening here is that the constraint is allowed to be violated by an amount proportional
to CFM times the restoring force that is needed to enforce the constraint.
Note that setting CFM to a negative value can have undesirable bad effects, such as instability. Don't do it.
The ERP specifies what proportion of the joint error will be fixed during the next simulation step.
If ERP=0 then no correcting force is applied and the bodies will eventually drift apart as the simulation proceeds.
If ERP=1 then the simulation will attempt to fix all joint error during the next time step.
However, setting ERP=1 is not recommended, as the joint error will not be completely fixed due to various internal approximations.
A value of ERP=0.1 to 0.8 is recommended (0.2 is the default).
Now to set the ERB and CFM values of your constraints, use the methods
where index 0-2 are for linear constraints, 3-5 for angular constraints
There are 2 parameters for that, called error reduction parameter (ERP) and constraint force mixing (CFM).
If you want to get more information on each, here is an article that explains it quite well (sorry, it's on the ODE wiki, but that's the only place where I could find it): http://opende.sourceforge.net/wiki/inde ... oncepts%29
But in short:
If CFM is set to zero, the constraint will be hard.
If CFM is set to a positive value, it will be possible to violate the constraint by "pushing on it"
(for example, for contact constraints by forcing the two contacting objects together).
In other words the constraint will be soft, and the softness will increase as CFM increases.
What is actually happening here is that the constraint is allowed to be violated by an amount proportional
to CFM times the restoring force that is needed to enforce the constraint.
Note that setting CFM to a negative value can have undesirable bad effects, such as instability. Don't do it.
The ERP specifies what proportion of the joint error will be fixed during the next simulation step.
If ERP=0 then no correcting force is applied and the bodies will eventually drift apart as the simulation proceeds.
If ERP=1 then the simulation will attempt to fix all joint error during the next time step.
However, setting ERP=1 is not recommended, as the joint error will not be completely fixed due to various internal approximations.
A value of ERP=0.1 to 0.8 is recommended (0.2 is the default).
Now to set the ERB and CFM values of your constraints, use the methods
Code: Select all
constraint->setParam(BT_CONSTRAINT_STOP_CFM, myCFMvalue, index)
constraint->setParam(BT_CONSTRAINT_STOP_ERP, myERPvalue, index)
-
- Posts: 50
- Joined: Fri Oct 29, 2010 1:37 am
Re: how to set btGeneric6DofConstraint's constraint force
Thanks Yann! That entire post should be added to the bullet constraint headers or pdf doc. This is info anyone using them should have easy access to.
-
- Posts: 4
- Joined: Sat Oct 15, 2011 3:47 pm
Re: how to set btGeneric6DofConstraint's constraint force
thanks. i have solved this problem by using btHingeConstraint and limiting it's joint Value 0 to 0.
Code: Select all
btHingeConstraint *fix = new btHingeConstraint(*bodyA, *bodyB, localA, localB);
fix->setLimit(0, 0);