Home › Forum › SOFA › Using SOFA › [SOLVED] Deformable Cylinder collision with floor
Tagged: 64_bits, Linux_ubuntu, Plugin_SoftRobots, SOFA_2006
- This topic has 6 replies, 2 voices, and was last updated 3 years, 11 months ago by Hugo.
-
AuthorPosts
-
26 October 2020 at 14:58 #17445ShanBlocked
Hi,
I am trying to simulate a deformable cylinder falling under the gravitational force, the simulation runs but then SOFA crashes. The code is as follows:
import Sofa import os from stlib.scene import MainHeader, ContactHeader from stlib.visuals import ShowGrid from stlib.physics.rigid import Floor #from stlib.physics.rigid import cube # import Sofa # import os def createScene(rootNode): ShowGrid(rootNode) # A default gravity force is implemented on Sofa. Here we reset it, choosing millimeters as the length unit for the scene. MainHeader(rootNode, gravity=[0.0,-981.0,0.0]) #Collision handling built-in function (already used in Step 1) ContactHeader(rootNode, alarmDistance=25, contactDistance=20) rootNode.createObject(‘FreeMotionAnimationLoop’) #rootNode.createObject(‘DefaultPipeline’, verbose=’0′, depth=’6′, draw=’1′) #rootNode.createObject(‘BruteForceDetection’, name=’N2′) cylinder = rootNode.createChild(“Cylinder”) ### Mechanical model totalMass = 1.0 volume = 1.0 inertiaMatrix = [1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0] cylinder.createObject(‘MeshVTKLoader’, name=’loader’, filename=’./TestActuator’) cylinder.createObject(‘Mesh’, src=’@loader’, name=’cylinderMesh’) cylinder.createObject(‘MechanicalObject’, name=”DOF”, template=”Vec3d”, translation=[0.0,0.0,0.0], rotation=[0.0,0.0,0.0]) #Making the cylinder flexible by adding TetrahedronFEMForceField with poissonRatio and youngModulus cylinder.createObject(‘TetrahedronFEMForceField’, template=”Vec3d”, name=’FEM’, method=’large’, poissonRatio=’0.3′, youngModulus=’500′, drawAsEdges=”true”) cylinder.createObject(‘UniformMass’, name=”vertexMass”, vertexMass=’./vertexMass.rigid’) # Material behaviour when submitted to constraints cylinder.createObject(‘UncoupledConstraintCorrection’) ### Time integration and solver cylinder.createObject(‘EulerImplicit’, name=’odesolver’) cylinder.createObject(‘CGLinearSolver’, name=’Solver’) ### Visual Object of the cylinder visual = cylinder.createChild(“cylinderVisual”) # Graphic model based on a mesh visual.createObject(‘OglModel’, name=”Visual”, src=’@../loader’,scale=5.0)#filename=”mesh/smcylinder27.obj”, color=[0.1,0.0,1.0], scale=20.0) # Building a correspondance between the mechanical and the graphical representation visual.createObject(‘IdentityMapping’, name=’mapping’, mapForces=’true’, mapMasses=’true’) ### Collision Object for the cylinder collision = cylinder.createChild(“cylinderCollisionModel”) #collision.createObject(‘MeshObjLoader’, name=”loader”, filename=”mesh/smcylinder27.obj”, triangulate=”true”, scale=20.0) collision.createObject(‘MeshTopology’, src=”@../loader”)#, triangulate=’1′) #collision.createObject(‘MeshTopology’) collision.createObject(‘MechanicalObject’) collision.createObject(‘Triangle’) collision.createObject(‘Line’) collision.createObject(‘Point’) collision.createObject(‘IdentityMapping’, name=’mapping1′, mapForces=’true’, mapMasses=’true’) ######################################## ### Adding the Floor for more fun 😉 ### floor = Floor(rootNode, name=”Floor”, translation=[10.0,-300.0,100.0], uniformScale=5.0, isAStaticObject=True) return rootNode
I am just trying to check the collision between a rigid and deformable objects.
Thanks in advance.Regards,
Shan.30 October 2020 at 15:33 #17500HugoKeymasterHi @shan
how did you generate this mesh? is this from SoftRobots plugin? It looks like a problem in the mesh topology.
Best
Hugo
4 November 2020 at 10:48 #17547ShanBlockedHi Hugo,
Thanks for the reply. I believe there could be the problem with the mesh. I generated the mesh using Gmsh. Do you have any suggestions, should I make the mesh finer for the collision simulation? I could also send you the geometry for you to check what is wrong with the mesh.
Best regards,
Shan.18 November 2020 at 08:21 #17711HugoKeymasterHi @shan
Could you please replace in your scene the part:
cylinder.createObject('Mesh', src='@loader', name='cylinderMesh') cylinder.createObject('MechanicalObject', name='DOF', template='Vec3d', translation=[0.0,0.0,0.0], rotation=[0.0,0.0,0.0])
with:
cylinder.createObject('TetrahedronSetTopologyContainer', name='topo') cylinder.createObject('MechanicalObject', name='DOF', template='Vec3d', position='@loader.position') cylinder.createObject('TetrahedronSetTopologyModifier', name='modifier')
It should work. Since some topology information is missing, it has to be computed by SOFA. But to do so, a Modifier must be added.
Best
Hugo
18 November 2020 at 16:54 #17722ShanBlockedHi Hugo,
Thanks for the reply. I made the changes you suggested, however now I have the following error:-
[ERROR] [TetrahedronFEMForceField(FEM)] object must have a tetrahedric topology. The component is inactivated. To remove this error message please add a tetrahedric topology component to your scene.
I changed the mesh as well, made it finer for collision problem.
Regards,
Shan19 November 2020 at 17:07 #17768ShanBlockedHi Hugo,
The scene seems to work now, I changed the mesh and I believe it was because the mesh for not refined properly that the Sofa scene was giving the error I mentioned above. So I guess the last query is resolved, however if you have any suggestions I would be happy to learn.
Best regards,
Shantanu.4 December 2020 at 23:12 #17941HugoKeymasterDear @shan
Great to read it works now.
The error you got with the TetrahedronFEMForceField was due to the fact the mesh loaded was not (or not properly) including tetrahedral elements.Let me know if you need more information on one of these matters.
Meanwhile, I close the topic. Do not hesitate to open a new one.Hugo
-
AuthorPosts
- You must be logged in to reply to this topic.