Home › Forum › SOFA › Using SOFA › Rigid models flying apart when colliding
Tagged: 64_bits, SOFA_1806, Windows_10
- This topic has 3 replies, 2 voices, and was last updated 5 years, 11 months ago by Hugo.
-
AuthorPosts
-
9 January 2019 at 11:42 #12740AnonymousInactive
I have a scissors model that is made out of 4 parts, I can manipulate the full scissors to move with code, but as soon as it collides with another model it breaks apart into the four pieces. I tried to fix this behaviour by only allowing the keyboard keys to move the scissors, that fixed the breaking apart a bit but it stills breaks apart.
Before fix:
After fix:
So is there a way to treat the four parts as one rigid body in SOFA, and only be able to manipulate it using the keyboard.
Best,
Fayad9 January 2019 at 15:25 #12747HugoKeymasterHi @fayad
In order to consider them all as Rigid parts, you can :
1. define one master Rigid node, with only one point
2. create subnodes for each Rigid part, and map them on the above single point with a RigidRigidMappingThus it would be considered as one rigid object.
Best
Hugo
10 January 2019 at 13:47 #12754AnonymousInactiveHi @Hugo
Thanks a lot, that worked, but now I am facing another problem with the rotation of individual parts, as I want to rotate the the tips, but I cannot since I have to rotate the master point to apply changes on the other parts, but it rotates everything which I dont want. In addition, after I collide with the prostate, the scissors start rotating and when I move the point it rotates instead of translating.
Sorry for the too many questions, thanks again
Best,
Fayad11 January 2019 at 11:28 #12765HugoKeymasterHi @fayad
I needed to investigate myself, here is a solution using the ArticulatedSystemMapping.
Scene:<?xml version="1.0" ?> <Node name="root" dt="0.02" gravity="0 0 0"> <RequiredPlugin name="SofaPython" pluginName="SofaPython" /> <PythonScriptController filename="ChangeOrientation.py" classname="Rotate" listening="true"/> <EulerImplicit /> <CGLinearSolver iterations="100" threshold="1e-6" tolerance="1e-6" /> <MechanicalObject name="bati" template="Rigid" position="0 0 0 0 0 0 1" /> <UniformMass /> <Node name="Grasper"> <MechanicalObject name="Articulations" template="Vec1d" position="0 0" /> <!-- rest_position="0 0.52" --> <RestShapeSpringsForceField points="0 1" stiffness="100000 100000" printLog="true"/> <Node name="Jaws"> <MechanicalObject name="GrasperDOFs" template="Rigid" position="0 0 0 0 0 0 1 0.1 0 0 0 0 0 1 0.2 0 0 0 0 0 1" showObject="1" showObjectScale="1"/> <Node name="visualization"> <Node name="handle_VM"> <OglModel name="VM" filename="mesh/dental_instrument.obj" color="red" /> <RigidMapping input="@../../GrasperDOFs" output="@VM" index="0" isMechanical="false" /> </Node> <Node name="grasper-bottom_VM"> <OglModel name="VM" filename="mesh/dental_instrument.obj" rx="90" color="green" /> <RigidMapping input="@../../GrasperDOFs" output="@VM" index="1" /> </Node> <Node name="grasper-top_VM"> <OglModel name="VM" filename="mesh/dental_instrument.obj" ry="90" color="blue" /> <RigidMapping input="@../../GrasperDOFs" output="@VM" index="2" /> </Node> </Node> <ArticulatedSystemMapping input1="@../Articulations" output="@GrasperDOFs" input2="@../../bati"/> </Node> <ArticulatedHierarchyContainer/> <Node name="articulationCenters"> <Node name="articulationCenter2"> <ArticulationCenter parentIndex="0" childIndex="1" posOnParent="0 0 -13" posOnChild="0 0 -13"/> <Node name="articulations"> <Articulation translation="0" rotation="1" rotationAxis="0 1 0" articulationIndex="0"/> </Node> </Node> <Node name="articulationCenter3"> <ArticulationCenter parentIndex="0" childIndex="2" posOnParent="0 0 -13" posOnChild="0 0 -13"/> <Node name="articulations"> <Articulation translation="0" rotation="1" rotationAxis="0 -1 0" articulationIndex="1"/> </Node> </Node> </Node> </Node> </Node>
with a python script:
import sys import Sofa class Rotate(Sofa.PythonScriptController): def initGraph(self,node): self.Articulations=node.getChild('Grasper').getObject('Articulations') return 0 def onKeyPressed(self,k): if k=="M" : rotation = self.Articulations.findData('position').value rotation[1][0] = rotation[1][0] - 0.1 self.Articulations.findData('position').value = rotation self.Articulations.findData('rest_position').value = rotation print ' M ' if k=="L" : rotation = self.Articulations.findData('position').value rotation[1][0] = rotation[1][0] + 0.1 self.Articulations.findData('position').value = rotation self.Articulations.findData('rest_position').value = rotation print ' L ' return 0
Do not hesitate to post us your resulting video 😉
Best wishes,Hugo
-
AuthorPosts
- You must be logged in to reply to this topic.