Trouble using AttachConstraint #4032
-
Hi guys ! I have some troubles using the node.addobject("AttachConstraint") function. To begin with, I did not fully understand how to obtain the list of indices of the two objects that we want to attach. For instance, in the example "AttachConstraint.scn" (that you can find here sofa/src/examples/Component/Constraint/Projective) we can find : <AttachConstraint object1="@M1" object2="@M2" indices1="144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159" indices2="0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15" constraintFactor="1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1"/> Problem is that how indices1 and indices2 are obtained ? def Disque(solverNode, translation, rotation):
#### MAPPING of the disks (here some torus) #### ###########
disque = solverNode.cosserat.rigidBase.cosseratInSofaFrameNode.addChild("DisqueMechanics")
totalMass = 0.006
volume = 0.000004247 #diametre = 52; epaisseur=2; masse=6.35g
inertiaMatrix = [0.000002028, 0.0, 0.0, 0.0, 0.000002028, 0.0, 0.0, 0.0, 0.000004056]
disque.addObject('EulerImplicit', name='odesolver')
disque.addObject('CGLinearSolver', name='Solver')
disque.addObject('MechanicalObject', name="DOF", template="Rigid3", translation=translation, rotation=rotation)
disque.addObject('UniformMass', name="vertexMass", vertexMass=[totalMass, volume, inertiaMatrix[:]])
# disque.addObject('UncoupledConstraintCorrection')
mapping = disque.addChild("Mapping")
mapping.addObject("MeshOBJLoader", name="meshLoader_2", filename="Disque.obj", scale="0.001", handleSeams="1", scale3d="1 1 1")
mapping.addObject("OglModel", name="Visual", src="@meshLoader_2", color="1.0 0.5 0.25 1.0")
mapping.addObject("RigidMapping", input="@..", output="@Visual", index="10")
########### ########### ########### ###########
return disque Finally, in my creatScene function I added (I chose indices randomly): However, this gave me this error :
Do you have an idea ? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 5 replies
-
For your first question: The selection of indices is still a pain in SOFA, you can find two tuto here: For your second question: AttachConstraint is a projective constraint which couples the two objects to have some of their degrees of freedom equal at the end of each time step through a projection. This is a "weak" projective constraint. It therefore assumes that both MechanicalObject that you couple have the same template. |
Beta Was this translation helpful? Give feedback.
An alternative could be Lagrangian constraint to control dofs, like in #4512