Skip to content

Commit

Permalink
[tutorials] cleaning PneunetGripper
Browse files Browse the repository at this point in the history
  • Loading branch information
EulalieCoevoet committed Nov 20, 2023
1 parent 3bfd660 commit 352c6ef
Show file tree
Hide file tree
Showing 11 changed files with 268 additions and 171 deletions.
4 changes: 2 additions & 2 deletions examples/tutorials/PneunetGripper/details/fingerController.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ class FingerController(Sofa.Core.Controller):
def __init__(self, *args, **kwargs):
Sofa.Core.Controller.__init__(self, args, kwargs)
self.node = args[0]
self.fingerNode = self.node.getChild('finger')
self.pressureConstraint = self.fingerNode.cavity.getObject('SurfacePressureConstraint')
self.fingerNode = self.node.getChild('Finger')
self.pressureConstraint = self.fingerNode.Cavity.getObject('SurfacePressureConstraint')

def onKeypressedEvent(self, e):
pressureValue = self.pressureConstraint.value.value[0]
Expand Down
64 changes: 31 additions & 33 deletions examples/tutorials/PneunetGripper/details/param.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
# -*- coding: utf-8 -*-
import math

#################### USER PARAM ##########################

cubeParam = { 'name' : "Cube",
'totalMass' : 0.0008,
'translation' : [15.0,20.0,0.0],
'uniformScale' : 21}

floorParam = { 'name' : "Plane",
'color' : [1.0, 0.0, 1.0],
'isAStaticObject' : True,
'uniformScale' : 10}
# User parameters
cubeParam = {'name': "Cube",
'totalMass': 0.01,
'translation': [15.0, 20.0, 0.0],
'uniformScale': 21}

floorParam = {'name': "Plane",
'color': [1.0, 0.0, 1.0],
'isAStaticObject': True,
'uniformScale': 3}

# Fingers Mesh & Shared Parameters
fingersVolumeMesh = 'data/mesh/pneunetCutCoarse.vtk'
Expand All @@ -25,33 +23,33 @@
# Fingers Position
heightInitial = 150
radius = 70
angle1 = 120*math.pi/180 # Angle between 1st and 2nd finger in radian
angle2 = 240*math.pi/180 # Angle between 1st and 3rd finger in radian
angle1 = 120 * math.pi / 180 # Angle between 1st and 2nd finger in radian
angle2 = 240 * math.pi / 180 # Angle between 1st and 3rd finger in radian

youngModulusFingers = 500
youngModulusStiffLayerFingers = 1500
poissonRatioFingers = 0.3
fingersMass = 0.04
cavitiesInitialValue = 0.0001

# Paramters for each Fingers
# Parameters for each Fingers
fingersParameters = [
{
'name' : 'finger1',
'rotation' : [0.0, 0.0, -270.0],
'translation' : [100.0, heightInitial , 0.0],
'ROIBox' : [100, heightInitial-10, -20, 70, heightInitial, 20],
},
{
'name' : 'finger2',
'rotation' : [360 - angle1*180/math.pi, 0.0, 90.0],
'translation' : [0, heightInitial, radius*math.cos(angle1-math.pi/2)],
'ROIBox' : [100, heightInitial-10, -20, 70, heightInitial, 20],
},
{
'name' : 'finger3',
'rotation' : [360 - angle2*180/math.pi, 0.0, 90.0],
'translation' : [0.0, heightInitial, radius*math.cos(angle2-math.pi/2)],
'ROIBox' : [100, heightInitial-10, -20, 70, heightInitial, 20],
}
]
{
'name': 'Finger1',
'rotation': [0.0, 0.0, -270.0],
'translation': [100.0, heightInitial, 0.0],
'ROIBox': [100, heightInitial - 10, -20, 70, heightInitial, 20],
},
{
'name': 'Finger2',
'rotation': [360 - angle1 * 180 / math.pi, 0.0, 90.0],
'translation': [0, heightInitial, radius * math.cos(angle1 - math.pi / 2)],
'ROIBox': [100, heightInitial - 10, -20, 70, heightInitial, 20],
},
{
'name': 'Finger3',
'rotation': [360 - angle2 * 180 / math.pi, 0.0, 90.0],
'translation': [0.0, heightInitial, radius * math.cos(angle2 - math.pi / 2)],
'ROIBox': [100, heightInitial - 10, -20, 70, heightInitial, 20],
}
]
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,13 @@

def createScene(rootNode):
rootNode.addObject('RequiredPlugin', pluginName='SoftRobots SofaPython3')
finger = rootNode.addChild('finger')
rootNode.addObject("DefaultAnimationLoop")

rootNode.addObject('RequiredPlugin', name='Sofa.Component.IO.Mesh') # Needed to use components [MeshVTKLoader]
rootNode.addObject('RequiredPlugin', name='Sofa.Component.StateContainer') # Needed to use components [MechanicalObject]
rootNode.addObject('RequiredPlugin', name='Sofa.Component.Topology.Container.Constant') # Needed to use components [MeshTopology]

finger = rootNode.addChild('Finger')
finger.addObject('MeshVTKLoader', name='loader', filename='data/mesh/pneunetCutCoarse.vtk')
finger.addObject('MeshTopology', src='@loader', name='container')
finger.addObject('MechanicalObject', name='tetras', template='Vec3', showObject=True, showObjectScale=1)
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,20 @@
def createScene(rootNode):
rootNode.addObject('VisualStyle', displayFlags='showForceFields')
rootNode.addObject('RequiredPlugin', pluginName='SoftRobots SofaPython3')
rootNode.findData('gravity').value = [-9810, 0, 0]
rootNode.gravity.value = [-9810, 0, 0]
rootNode.addObject("DefaultAnimationLoop")

finger = rootNode.addChild('finger')
rootNode.addObject('RequiredPlugin', name='Sofa.Component.IO.Mesh') # Needed to use components [MeshVTKLoader]
rootNode.addObject('RequiredPlugin', name='Sofa.Component.StateContainer') # Needed to use components [MechanicalObject]
rootNode.addObject('RequiredPlugin', name='Sofa.Component.Topology.Container.Constant') # Needed to use components [MeshTopology]
rootNode.addObject('RequiredPlugin', name='Sofa.Component.Mass') # Needed to use components [UniformMass]
rootNode.addObject('RequiredPlugin', name='Sofa.Component.SolidMechanics.FEM.Elastic') # Needed to use components [TetrahedronFEMForceField]
rootNode.addObject('RequiredPlugin', name='Sofa.Component.Visual') # Needed to use components [VisualStyle]

finger = rootNode.addChild('Finger')
finger.addObject('MeshVTKLoader', name='loader', filename='data/mesh/pneunetCutCoarse.vtk')
finger.addObject('MeshTopology', src='@loader', name='container')
finger.addObject('MechanicalObject', name='tetras', template='Vec3', showObject=True, showObjectScale=1)
finger.addObject('TetrahedronFEMForceField', template='Vec3', name='FEM', method='large', poissonRatio=0.3,
youngModulus=500)
finger.addObject('UniformMass', totalMass=0.0008)
finger.addObject('UniformMass', totalMass=0.04)
24 changes: 17 additions & 7 deletions examples/tutorials/PneunetGripper/details/step3-stiffLayer.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,31 @@


def createScene(rootNode):
rootNode.addObject('VisualStyle', displayFlags='showForceFields')
rootNode.addObject('VisualStyle', displayFlags='showForceFields showWireframe')
rootNode.addObject('RequiredPlugin', pluginName='SoftRobots SofaPython3')
rootNode.findData('gravity').value = [-9810, 0, 0];
rootNode.gravity.value = [-9810, 0, 0]
rootNode.addObject("DefaultAnimationLoop")

finger = rootNode.addChild('finger')
rootNode.addObject('RequiredPlugin', name='Sofa.Component.Engine.Select') # Needed to use components [BoxROI]
rootNode.addObject('RequiredPlugin', name='Sofa.Component.IO.Mesh') # Needed to use components [MeshVTKLoader]
rootNode.addObject('RequiredPlugin', name='Sofa.Component.Mass') # Needed to use components [UniformMass]
rootNode.addObject('RequiredPlugin', name='Sofa.Component.SolidMechanics.FEM.Elastic') # Needed to use components [TetrahedronFEMForceField]
rootNode.addObject('RequiredPlugin', name='Sofa.Component.StateContainer') # Needed to use components [MechanicalObject]
rootNode.addObject('RequiredPlugin', name='Sofa.Component.Topology.Container.Constant') # Needed to use components [MeshTopology]
rootNode.addObject('RequiredPlugin', name='Sofa.Component.Visual') # Needed to use components [VisualStyle]

finger = rootNode.addChild('Finger')
finger.addObject('MeshVTKLoader', name='loader', filename='data/mesh/pneunetCutCoarse.vtk')
finger.addObject('MeshTopology', src='@loader', name='container')
finger.addObject('MechanicalObject', name='tetras', template='Vec3', showObject=True, showObjectScale=1)
finger.addObject('TetrahedronFEMForceField', template='Vec3', name='FEM', method='large', poissonRatio=0.3,
youngModulus=500)
finger.addObject('UniformMass', totalMass=0.0008)
finger.addObject('BoxROI', name='boxROISubTopo', box=[-100, 22.5, -8, -19, 28, 8], drawBoxes=True, strict=False)
finger.addObject('UniformMass', totalMass=0.04)
boxROISubTopo = finger.addObject('BoxROI', name='boxROISubTopo', box=[-100, 22.5, -8, -19, 28, 8],
drawBoxes=True, strict=False)

modelSubTopo = finger.addChild('modelSubTopo')
modelSubTopo.addObject('MeshTopology', position='@loader.position', tetrahedra='@boxROISubTopo.tetrahedraInROI',
modelSubTopo = finger.addChild('SubTopology')
modelSubTopo.addObject('MeshTopology', position='@loader.position', tetrahedra=boxROISubTopo.tetrahedraInROI.linkpath,
name='container')
modelSubTopo.addObject('TetrahedronFEMForceField', template='Vec3', name='FEM', method='large', poissonRatio=0.3,
youngModulus=1500)
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,31 @@ def createScene(rootNode):
rootNode.addObject('VisualStyle', displayFlags='showForceFields showBehavior')
rootNode.addObject('RequiredPlugin',
pluginName='SoftRobots SofaPython3')
rootNode.findData('gravity').value = [-9810, 0, 0]
rootNode.gravity.value = [-9810, 0, 0]
rootNode.addObject("DefaultAnimationLoop")

finger = rootNode.addChild('finger')
rootNode.addObject('RequiredPlugin', name='Sofa.Component.Engine.Select') # Needed to use components [BoxROI]
rootNode.addObject('RequiredPlugin', name='Sofa.Component.IO.Mesh') # Needed to use components [MeshVTKLoader]
rootNode.addObject('RequiredPlugin', name='Sofa.Component.Mass') # Needed to use components [UniformMass]
rootNode.addObject('RequiredPlugin', name='Sofa.Component.SolidMechanics.FEM.Elastic') # Needed to use components [TetrahedronFEMForceField]
rootNode.addObject('RequiredPlugin', name='Sofa.Component.SolidMechanics.Spring') # Needed to use components [RestShapeSpringsForceField]
rootNode.addObject('RequiredPlugin', name='Sofa.Component.StateContainer') # Needed to use components [MechanicalObject]
rootNode.addObject('RequiredPlugin', name='Sofa.Component.Topology.Container.Constant') # Needed to use components [MeshTopology]
rootNode.addObject('RequiredPlugin', name='Sofa.Component.Visual') # Needed to use components [VisualStyle]

finger = rootNode.addChild('Finger')
finger.addObject('MeshVTKLoader', name='loader', filename='data/mesh/pneunetCutCoarse.vtk')
finger.addObject('MeshTopology', src='@loader', name='container')
finger.addObject('MechanicalObject', name='tetras', template='Vec3', showObject=True, showObjectScale=1)
finger.addObject('TetrahedronFEMForceField', template='Vec3', name='FEM', method='large', poissonRatio=0.3,
youngModulus=500)
finger.addObject('UniformMass', totalMass=0.0008)
finger.addObject('BoxROI', name='boxROISubTopo', box=[-100, 22.5, -8, -19, 28, 8], strict=False)
finger.addObject('BoxROI', name='boxROI', box=[-10, 0, -20, 0, 30, 20], drawBoxes=True)
finger.addObject('RestShapeSpringsForceField', points='@boxROI.indices', stiffness=1e12, angularStiffness=1e12)
finger.addObject('UniformMass', totalMass=0.04)
boxROISubTopo = finger.addObject('BoxROI', name='boxROISubTopo', box=[-100, 22.5, -8, -19, 28, 8], strict=False)
boxROI = finger.addObject('BoxROI', name='boxROI', box=[-10, 0, -20, 0, 30, 20], drawBoxes=True)
finger.addObject('RestShapeSpringsForceField', points=boxROI.indices.linkpath, stiffness=1e12, angularStiffness=1e12)

modelSubTopo = finger.addChild('modelSubTopo')
modelSubTopo.addObject('MeshTopology', position='@loader.position', tetrahedra='@boxROISubTopo.tetrahedraInROI',
name='container')
modelSubTopo = finger.addChild('SubTopology')
modelSubTopo.addObject('MeshTopology', position='@loader.position', name='container',
tetrahedra=boxROISubTopo.tetrahedraInROI.linkpath)
modelSubTopo.addObject('TetrahedronFEMForceField', template='Vec3', name='FEM', method='large', poissonRatio=0.3,
youngModulus=1500)
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,37 @@ def createScene(rootNode):
rootNode.addObject('VisualStyle', displayFlags='showForceFields')
rootNode.addObject('RequiredPlugin',
pluginName='SoftRobots SofaPython3')
rootNode.findData('gravity').value = [-9810, 0, 0]
rootNode.gravity.value = [-9810, 0, 0]
rootNode.addObject('AttachBodyButtonSetting', stiffness=10)
rootNode.addObject("DefaultAnimationLoop")

finger = rootNode.addChild('finger')
finger.addObject('EulerImplicitSolver', name='odesolver')
finger.addObject('SparseLDLSolver', name='directSolver')
rootNode.addObject('RequiredPlugin', name='Sofa.Component.Engine.Select') # Needed to use components [BoxROI]
rootNode.addObject('RequiredPlugin', name='Sofa.Component.IO.Mesh') # Needed to use components [MeshVTKLoader]
rootNode.addObject('RequiredPlugin', name='Sofa.Component.LinearSolver.Direct') # Needed to use components [SparseLDLSolver]
rootNode.addObject('RequiredPlugin', name='Sofa.Component.Mass') # Needed to use components [UniformMass]
rootNode.addObject('RequiredPlugin', name='Sofa.Component.ODESolver.Backward') # Needed to use components [EulerImplicitSolver]
rootNode.addObject('RequiredPlugin', name='Sofa.Component.SolidMechanics.FEM.Elastic') # Needed to use components [TetrahedronFEMForceField]
rootNode.addObject('RequiredPlugin', name='Sofa.Component.SolidMechanics.Spring') # Needed to use components [RestShapeSpringsForceField]
rootNode.addObject('RequiredPlugin', name='Sofa.Component.StateContainer') # Needed to use components [MechanicalObject]
rootNode.addObject('RequiredPlugin', name='Sofa.Component.Topology.Container.Constant') # Needed to use components [MeshTopology]
rootNode.addObject('RequiredPlugin', name='Sofa.Component.Visual') # Needed to use components [VisualStyle]
rootNode.addObject('RequiredPlugin', name='Sofa.GUI.Component') # Needed to use components [AttachBodyButtonSetting]

finger = rootNode.addChild('Finger')
finger.addObject('EulerImplicitSolver')
finger.addObject('SparseLDLSolver', template='CompressedRowSparseMatrixd')
finger.addObject('MeshVTKLoader', name='loader', filename='data/mesh/pneunetCutCoarse.vtk')
finger.addObject('MeshTopology', src='@loader', name='container')
finger.addObject('MechanicalObject', name='tetras', template='Vec3', showObject=True, showObjectScale=1)
finger.addObject('TetrahedronFEMForceField', template='Vec3', name='FEM', method='large', poissonRatio=0.3,
youngModulus=500)
finger.addObject('UniformMass', totalMass=0.0008)
finger.addObject('BoxROI', name='boxROISubTopo', box=[-100, 22.5, -8, -19, 28, 8], strict=False)
finger.addObject('BoxROI', name='boxROI', box=[-10, 0, -20, 0, 30, 20], drawBoxes=True)
finger.addObject('RestShapeSpringsForceField', points='@boxROI.indices', stiffness=1e12, angularStiffness=1e12)
finger.addObject('UniformMass', totalMass=0.04)
boxROISubTopo = finger.addObject('BoxROI', name='boxROISubTopo', box=[-100, 22.5, -8, -19, 28, 8], strict=False)
boxROI = finger.addObject('BoxROI', name='boxROI', box=[-10, 0, -20, 0, 30, 20], drawBoxes=True)
finger.addObject('RestShapeSpringsForceField', points=boxROI.indices.linkpath, stiffness=1e12, angularStiffness=1e12)

modelSubTopo = finger.addChild('modelSubTopo')
modelSubTopo.addObject('MeshTopology', position='@loader.position', tetrahedra='@boxROISubTopo.tetrahedraInROI',
modelSubTopo = finger.addChild('SubTopology')
modelSubTopo.addObject('MeshTopology', position='@loader.position', tetrahedra=boxROISubTopo.tetrahedraInROI.linkpath,
name='container')
modelSubTopo.addObject('TetrahedronFEMForceField', template='Vec3', name='FEM', method='large', poissonRatio=0.3,
youngModulus=1500)
Loading

0 comments on commit 352c6ef

Please sign in to comment.