Home › Forum › SOFA › Using SOFA › [SOLVED] Two-way force propagation
Tagged: 64_bits, Linux_ubuntu, SOFA_1712
- This topic has 10 replies, 3 voices, and was last updated 6 years, 2 months ago by Rishabh.
-
AuthorPosts
-
6 September 2018 at 16:29 #11899NouraBlocked
Hello,
I the following simulation, object1 and object2 are assembled using the
AttachConstraint
component.
I noticed that when applying a constant force field to object1 (remove comment from tag1 in the scene), the simulation works as expected meaning that object1 is pulling object2.
Whereas when applying a constant force field to object2 (see tag2 in the scene), the force is not propagated to object1, and object2 is not able to pull object1 as expected.I also tried to set the
twoWay
parameter to “true” (see tag3) as explained in the source code to allow forces propagating in both directions. However, it doesn’t work as well.<?xml version="1.0"?> <Node name="root" gravity="0 0 0" dt="0.01" > <VisualStyle name="visualStyle1" displayFlags="showBehaviorModels showForceFields showInteractionForceFields showCollisionModels showWireframe" /> <EulerImplicitSolver rayleighStiffness="0.01"/> <CGLinearSolver iterations="50" tolerance="1e-06" threshold="1e-06"/> <Node name="object1" activated="1" > <MechanicalObject name="MO_object1" template="Rigid3d" position="-0.010686 -0.012517 -0.021330 0 0 0 0" /> <UniformMass totalmass="1" /> <Node name="object1_surf" activated="1" > <MeshObjLoader name="loader" filename="object1.obj" /> <Mesh src="@loader" /> <MechanicalObject name="MO_object1_surf" template="Vec3d" src="@loader" dx="0.010686" dy="0.012517" dz="0.021330"/> <RigidMapping /> </Node> <Node name="VisualModel"> <OglModel name="Visual" fileMesh="object1.obj" color="blue" dx="0.010686" dy="0.012517" dz="0.021330"/> <RigidMapping input="@.." output="@Visual"/> </Node> <!-- tag1: This works fine meaning that object1 pulls object2 --> <!-- <ConstantForceField indices="0" totalForce="50 0 0" arrowSizeCoef="0.25"/> --> </Node> <Node name="object2" activated="1"> <MeshSTLLoader name="meshLoader" filename="object2.stl" /> <Mesh src="@meshLoader"/> <MechanicalObject template="Vec3d" name="MO" src="@meshLoader" velocity="0 0 0"/> <UniformMass totalmass="1" /> <MeshSpringForceField name="deformable_object" stiffness="50000" damping="0.5" /> <Node name="VisualModel"> <OglModel name="Visual" fileMesh="object2.stl" color="yellow" translation="0 0 0" /> <IdentityMapping /> </Node> <!-- tag2: This doesn't work meaning that object2 does not pull object1 --> <ConstantForceField indices="0 2 15 21 27 32 " totalForce="-50 0 0" arrowSizeCoef="1"/> </Node> <AttachConstraint object1="@object1/object1_surf" object2="@object2" indices1="147 660 659 658 346" indices2="9 19 26 36 42" constraintFactor="1 1 1 1 1" twoWay="false"/> <!-- tag3: assinging true to twoWay param leads to a wrong simulation --> <!-- <AttachConstraint object1="@object1/object1_surf" object2="@object2" indices1="147 660 659 658 346" indices2="9 19 26 36 42" constraintFactor="1 1 1 1 1" twoWay="true"/> --> </Node>
I would appreciate if someone gives a look at the minimal scene (you can find the necessary files here).
Thanks,
Noura
21 September 2018 at 11:10 #11977HugoKeymasterHi @noura,
The AttachConstraint is a projective constraint and is templated. Therefore you need to carefully select the object you want to attach (with the same template).
In you case, the rigid MechanicalObject ‘MO_object1’ is the ‘master’ object for object 1, even if the physics occurs in on the deformable (since it has a template Vec3d) object 1 (MO_object1_surf). Why do you need this rigid MechanicalObject ‘MO_object1’?
I ran a simulation without this rigid MO and I added physics (stiffness and mass) to the MO_object1_surf and the AttachConstraint twoway worked well:
with one ConstantForce
with two ConstantForces
Scene :
<Node name="root" gravity="0 0 0" dt="0.01" > <VisualStyle name="visualStyle1" displayFlags="showBehaviorModels showForceFields showInteractionForceFields showCollisionModels showWireframe" /> <EulerImplicitSolver rayleighStiffness="0.01"/> <CGLinearSolver iterations="50" tolerance="1e-06" threshold="1e-06"/> <Node name="object1" activated="1" > <Node name="object1_surf" activated="1" > <MeshObjLoader name="loader" filename="object1.obj" /> <Mesh src="@loader" /> <MechanicalObject name="MO_object1_surf" template="Vec3d" src="@loader" showObject="1"/> <MeshSpringForceField name="deformable_object" stiffness="50000" damping="0.5" /> <UniformMass totalmass="1" /> <ConstantForceField indices="0 2 15 21 27 32" totalForce="50 0 0" arrowSizeCoef="1"/> <Node name="VisualModel"> <OglModel name="Visual" src="@../loader" color="blue" dx="0.010686" dy="0.012517" dz="0.021330"/> <BarycentricMapping input="@.." output="@Visual"/> </Node> </Node> </Node> <Node name="object2" activated="1"> <MeshSTLLoader name="meshLoader" filename="object2.stl" /> <Mesh src="@meshLoader"/> <MechanicalObject template="Vec3d" name="MO" src="@meshLoader" velocity="0 0 0"/> <UniformMass totalmass="1" /> <MeshSpringForceField name="deformable_object" stiffness="50000" damping="0.5" /> <Node name="VisualModel"> <OglModel name="Visual" src="@../meshLoader" color="yellow" translation="0 0 0" /> <IdentityMapping /> </Node> <ConstantForceField indices="0 2 15 21 27 32" totalForce="-50 0 0" arrowSizeCoef="1"/> </Node> <AttachConstraint object1="@object1/object1_surf" object2="@object2" indices1="147 660 659 658 346" indices2="9 19 26 36 42" constraintFactor="1 1 1 1 1" twoWay="true"/> </Node>
Best
Hugo
21 September 2018 at 16:28 #11989NouraBlockedHi Hugo,
Thanks for looking into the scene. Yes, I see your notice about the usage of different templates in a projective constraint is very relevant and now, at least, I understand why the behaviour is not as expected.
Concerning your question about the need of
MO_object1
:
I use it is because the cube should be a rigid object and not a deformable one as “object2”! so one point (the center of the cube should be sufficient for the mechaical object as far as I know). Then, I use theobject1_surf
just for the collision model and not as the master object for “object1”.
This is why I think that adding aMeshSpringForceField
inside theobject1_surf
as you suggested, even if it makes the simulation looks working, is not unfortunately the simulation I’m trying to get.To conclude, I already noticed that the attach constraints work fine in two way when both objects are deformble. However, they are not the suitable component to attach a rigid object with a deformable one! I’m trying to figure out a different way to do it.
Thanks again Hugo!
Noura
24 September 2018 at 18:52 #11999HugoKeymasterHey Noura,
I think here is what you are looking for:
<?xml version="1.0"?> <Node name="root" gravity="0 0 0" dt="0.003" > <VisualStyle name="visualStyle1" displayFlags="showBehaviorModels showForceFields showInteractionForceFields showCollisionModels showWireframe" /> <EulerImplicitSolver rayleighStiffness="0.01"/> <CGLinearSolver iterations="50" tolerance="1e-06" threshold="1e-06"/> <FreeMotionAnimationLoop /> <GenericConstraintSolver tolerance="0.001" maxIterations="1000"/> <Node name="object1" activated="1" > <MechanicalObject name="MO_object1" template="Rigid" position="-0.010686 -0.012517 -0.021330 0 0 0 0" velocity="10 0 0 0 0 0 0"/> <UniformMass totalMass="0.1" /> <UncoupledConstraintCorrection compliance="1"/> <Node name="object1_surf" activated="1" > <MeshObjLoader name="loader" filename="object1.obj" /> <Mesh src="@loader" /> <MechanicalObject name="MO_object1_surf" template="Vec3d" src="@loader" dx="0.010686" dy="0.012517" dz="0.021330" showObject="1"/> <UniformMass totalMass="0.1" /> <UncoupledConstraintCorrection compliance="1"/> <RigidMapping input="@.." output="@MO_object1_surf"/> <Node name="VisualModel"> <OglModel name="Visual" src="@../loader" color="blue" dx="0.010686" dy="0.012517" dz="0.021330"/> <IdentityMapping input="@.." output="@Visual"/> </Node> </Node> </Node> <Node name="object2" activated="1"> <MeshSTLLoader name="meshLoader" filename="object2.stl" /> <Mesh src="@meshLoader"/> <MechanicalObject template="Vec3d" name="MO" src="@meshLoader" velocity="0 0 0"/> <UniformMass totalMass="1" /> <MeshSpringForceField name="deformable_object" stiffness="50000" damping="0.5" /> <ConstantForceField indices="0 2 15 21 27 32 " totalForce="-5000 0 0" arrowSizeCoef="0.1"/> <UncoupledConstraintCorrection compliance="1"/> <Node name="VisualModel"> <OglModel name="Visual" src="@../meshLoader" color="yellow" translation="0 0 0" /> <IdentityMapping /> </Node> </Node> <BilateralInteractionConstraint template="Vec3d" object1="@object1/object1_surf" object2="@object2" first_point= "147 660 659 658 346 " second_point="9 19 26 36 42" /> </Node>
Cheers
Hugo
25 September 2018 at 16:23 #12012NouraBlockedHi Hugo,
Yes, it is working as desired right now! Thanks a lot.
Besides the sensitivity to the dt, mass and force values, I realized that the main issue was due to the absence of the “compliance” parameter in the “UncoupledConstraintCorrection”!.
I also noticed that by removing the mass and constraint correction from the “object1_surf” node, the simulation looks better because both objects will stay closely together even when pulling and interacting with one of them without contact “gap”.
Thanks also for the interesting thread which helps a lot understanding how these constraints work.
Best,
Noura
25 September 2018 at 16:45 #12013HugoKeymasterHey @noura
You are very welcome!
Note that the compliance for you information corresponds to the inverse of the A matrix of your Ax=b system.
Moreover, regarding the constraint, and the thread you were mentioning, that I will very soon make some update in the doc. You feedback about this upcoming update would be most welcome.Best
Hugo
4 October 2018 at 15:34 #12095RishabhBlockedThank you for your reply on post
That question was a part of a bigger problem I am trying to solve, so I will ask you about the main problem here which is more related to this thread
I am working on a cloth simulation as shown in this image,
image
and my task is to attach a given point on the cloth to another object (can be anything) whose motion I control through external commands. I have been looking at AttachConstraint without any luck, can you please help in this regardThe script to my scene is pasted here
Feel free to change the scene file as required
Thank you,
Rishabh4 October 2018 at 20:10 #12097HugoKeymasterYou should have a look to my previous message, applying the same structure to your case will make the cloth controlled by a rigid object.
Best,
Hugi
5 October 2018 at 15:14 #12111RishabhBlockedHi @hugo
Thanks a lot, I figured out how to AttachConstraint the cloth with the object π
But now, I am trying to find a way to deactivate the AttachConstraint through a python script, simply doing
attachConstraintObj.activated = False
does not help as there is no activated attribute. Is there a way I can deactivate the constraint through a python script?Thanks,
Rishabh5 October 2018 at 15:30 #12114RishabhBlockedHi, by the way I also tried to just make the
constraintFactor = 0
but that does not seem to work, it does not allow me to change the constraint factor from the python script. Any help on this would be appreciated!Thanks,
Rishabh
5 October 2018 at 15:39 #12115 -
AuthorPosts
- You must be logged in to reply to this topic.