Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions examples/.scene-tests
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
# Scenes to reduce are too heavy and slow to be simulated, so compute only a few iterations

# Organs
iterations "organs/liver/liverFine.pyscn" "10"
timeout "organs/liver/liverFine.pyscn" "120"

# Organs/liver
# Original scenes are tested with timout. Reduced versions and debug scenes are tested
iterations "organs/liver/liverFineHyperElastic.pyscn" "10"
timeout "organs/liver/liverFineHyperElastic.pyscn" "120"

iterations "organs/liver/liverFine_rotationalActuation.py" "10"
timeout "organs/liver/liverFine_rotationalActuation.py" "120"

iterations "organs/liver/liverFine_gravity.py" "10"
timeout "organs/liver/liverFine_gravity.py" "120"

iterations "organs/liver/liverFine_rotationalActuation.py" "10"
timeout "organs/liver/liverFine_rotationalActuation.py" "120"


# Others
iterations "others/caduceus/SphereOnAPlane.softSphereFalling.pyscn" "10"
Expand All @@ -31,3 +29,6 @@ timeout "softRobots/multiGait/reduced/reduced_multiGait.py" "120"

ignore "softRobots/multiGait/reducedMultiGait-softRobot.pyscn" # TODO fix: MechanicalMatrixMapperMOR is missing
ignore "softRobots/multiGait/reduced/debug/debug_scene.py" # TODO fix: ODE solver is not copied during reduction process

ignore "softRobots/sofiaLeg/sofiaComplete/sofiaSixLegs.py" # TODO fix: many errors in the scripts, methods signature changed, SOFA scene using old SofaPython API
ignore "softRobots/sofiaLeg/sofiaComplete/DemoSofia.py" # TODO fix: depends on sofiaSixLegs.py . Should be fixed if sofiaSixLegs.py is working
39 changes: 32 additions & 7 deletions examples/bouncingBall/softSphereFalling.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,38 @@
pathMesh = os.path.dirname(os.path.abspath(__file__))+'/'
# Units: mm, kg, s. Pressure in kPa = k (kg/(m.s^2)) = k (g/(mm.s^2) = kg/(mm.s^2)

plugins=['SofaPython3',
'Sofa.Component.Collision.Detection.Algorithm',
'Sofa.Component.Visual',
'Sofa.Component.AnimationLoop',
'Sofa.Component.Collision.Detection.Intersection',
'Sofa.Component.Collision.Geometry',
'Sofa.Component.Collision.Response.Contact',
'Sofa.Component.Constraint.Lagrangian.Correction',
'Sofa.Component.Constraint.Lagrangian.Solver',
'Sofa.Component.IO.Mesh',
'Sofa.Component.LinearSolver.Direct',
'Sofa.Component.Mapping.Linear',
'Sofa.Component.Mass',
'Sofa.Component.ODESolver.Backward',
'Sofa.Component.SolidMechanics.FEM.Elastic',
'Sofa.Component.StateContainer',
'Sofa.Component.Topology.Container.Constant',
'Sofa.Component.Topology.Container.Dynamic',
'Sofa.Component.Visual',
'Sofa.GL.Component.Rendering3D'
]

def createScene(rootNode):
rootNode.addObject('RequiredPlugin', pluginName=plugins, printLog=False)

rootNode.addObject('VisualStyle', displayFlags='showVisualModels hideBehaviorModels showCollisionModels hideBoundingCollisionModels showForceFields showInteractionForceFields hideWireframe')
rootNode.gravity=[0,-9810, 0]
rootNode.dt = 0.0001
rootNode.addObject('FreeMotionAnimationLoop')
rootNode.addObject('GenericConstraintSolver', name='GSSolver', maxIterations='10000', tolerance='1e-15')
rootNode.addObject('CollisionPipeline', verbose="0")
rootNode.addObject('BruteForceBroadPhase', name="N2")
rootNode.addObject('CollisionPipeline', verbose='0')
rootNode.addObject('BruteForceBroadPhase', name='N2')
rootNode.addObject('BVHNarrowPhase')
rootNode.addObject('CollisionResponse', response="FrictionContactConstraint", responseParams="mu=0.0")
rootNode.addObject('LocalMinDistance', name="Proximity", alarmDistance="8.0", contactDistance="0.5", angleCone="0.01")
Expand All @@ -29,7 +53,7 @@ def createScene(rootNode):
sphereTranslation = [0,10,0]
model = solverNode.addChild('model')
model.addObject('MeshVTKLoader', name='loader', filename=pathMesh+'sphere.vtk', translation=sphereTranslation)
model.addObject('Mesh',src = '@loader')
model.addObject('MeshTopology',src = '@loader')
model.addObject('MechanicalObject', name='tetras', template='Vec3d', showIndices='false', showIndicesScale='4e-5', rx='0',printLog="0")
# model.addObject('WriteState', name="StateWriter", filename="fullBall.state",period="0.001", writeX=True, writeX0=True, writeV=False, writeF=False, time=0)
model.addObject('UniformMass', totalMass='0.2', printLog='0')
Expand All @@ -48,13 +72,14 @@ def createScene(rootNode):
rotation=[0,0,0]
#rotation=[30,0,0]
planeNode = rootNode.addChild('Plane')
planeNode.addObject('MeshObjLoader', name='loader', filename="mesh/floorFlat.obj", triangulate="true",rotation=rotation)
planeNode.addObject('Mesh', src="@loader")
planeNode.addObject('MeshOBJLoader', name='loader', filename="mesh/floorFlat.obj", triangulate="true", rotation=rotation)
planeNode.addObject('MeshTopology', src="@loader")
planeNode.addObject('MechanicalObject', src="@loader", rotation="0 0 0", translation="0 0 0", scale="1")
planeNode.addObject('TriangleCollisionModel',simulated="0", moving="0",group="1",name='TriPlane')
planeNode.addObject('LineCollisionModel',simulated="0", moving="0",group="1")
planeNode.addObject('PointCollisionModel',simulated="0", moving="0",group="1")
planeNode.addObject('OglModel',name="Visual", fileMesh="mesh/floorFlat.obj", color="1 0 0 1",rotation=rotation, translation="0 0 0", scale="1")
planeNode.addObject('UncoupledConstraintCorrection')
planeNode.addObject('OglModel',name="Visual", src="@loader", color="1 0 0 1", rotation=rotation, translation="0 0 0", scale="1")

return rootNode


29 changes: 17 additions & 12 deletions examples/bouncingBall/softSphereFalling_reduced.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,17 @@
pathMesh = os.path.dirname(os.path.abspath(__file__))+'/'
nbrOfModes = 15
# Units: mm, kg, s. Pressure in kPa = k (kg/(m.s^2)) = k (g/(mm.s^2) = kg/(mm.s^2)
plugins=["SofaPython3","SoftRobots","ModelOrderReduction","STLIB",
plugins=['SofaPython3','ModelOrderReduction','STLIB',
# normally plugin Sofa.Component is enough but still warning
"Sofa.Component.Visual",
"Sofa.Component.AnimationLoop",
"Sofa.GL.Component.Rendering3D",
"Sofa.Component.Constraint.Lagrangian.Solver",
'Sofa.Component.Visual',
'Sofa.Component.AnimationLoop',
'Sofa.GL.Component.Rendering3D',
'Sofa.Component.Constraint.Lagrangian.Solver',
'Sofa.Component.Collision.Detection.Algorithm',
'Sofa.Component.Collision.Detection.Intersection',
'Sofa.Component.Collision.Geometry',
'Sofa.Component.Collision.Response.Contact',
'Sofa.Component.Topology.Container.Constant',
'Sofa.Component.IO.Mesh',
'Sofa.Component.Playback',
'Sofa.Component.Constraint.Lagrangian.Correction', # Needed to use components [GenericConstraintCorrection]
Expand All @@ -24,6 +29,7 @@
'Sofa.Component.StateContainer', # Needed to use components [MechanicalObject]
'Sofa.Component.Topology.Container.Dynamic'] # Needed to use components [TetrahedronSetTopologyContainer]


def createScene(rootNode):

rootNode.addObject('RequiredPlugin', pluginName=plugins, printLog=False)
Expand Down Expand Up @@ -54,15 +60,15 @@ def createScene(rootNode):

model = modesNode.addChild('model')
model.addObject('MeshVTKLoader', name='loader', filename=pathMesh+'sphere.vtk', translation=sphereTranslation)
model.addObject('Mesh',src = '@loader')
model.addObject('MeshTopology',src = '@loader')
model.addObject('MechanicalObject', name='tetras', template='Vec3d', showIndices='false', showIndicesScale='4e-5', rx='0',printLog="0")
# model.addObject('WriteState', name="StateWriter", filename="fullBall.state",period="0.001", writeX=True, writeX0=True, writeV=False, writeF=False, time=0)
model.addObject('UniformMass', totalMass='0.2', printLog='0')
# model.addObject('TetrahedronFEMForceField', template='Vec3d',youngModulus=1.0e3,poissonRatio=0.45)
# model.addObject('HyperReducedTetrahedronFEMForceField' , template = 'Vec3', method = 'large', name = 'reducedFF_modelNode_0', poissonRatio = 0.45, youngModulus = 1.0e3, nbModes = nbrOfModes, prepareECSW = True, performECSW = False, modesPath = 'modes.txt',nbTrainingSet=100,periodSaveGIE=10)
model.addObject('HyperReducedTetrahedronFEMForceField' , template = 'Vec3', method = 'large', name = 'reducedFF_modelNode_0', poissonRatio = 0.45, youngModulus = 1.0e3, nbModes = nbrOfModes, prepareECSW = False, performECSW = True, modesPath = 'modes.txt', RIDPath='RID.txt',weightsPath='weights.txt')
model.addObject('HyperReducedTetrahedronFEMForceField' , template = 'Vec3', method = 'large', name = 'reducedFF_modelNode_0', poissonRatio = 0.45, youngModulus = 1.0e3, nbModes = nbrOfModes, prepareECSW = False, performECSW = True, modesPath = pathMesh + 'modes.txt', RIDPath = pathMesh + 'RID.txt', weightsPath = pathMesh + 'weights.txt')

model.addObject('ModelOrderReductionMapping' , input = '@../modes', modesPath = 'modes.txt', output = '@./tetras')
model.addObject('ModelOrderReductionMapping' , input = '@../modes', modesPath = pathMesh + 'modes.txt', output = '@./tetras')

modelCollis = model.addChild('modelCollis')
modelCollis.addObject('MeshSTLLoader', name='loader', filename=pathMesh+'sphere.stl', rotation="0 0 0", translation=sphereTranslation)
Expand All @@ -77,13 +83,12 @@ def createScene(rootNode):
rotation=[0,0,0]
#rotation=[30,0,0]
planeNode = rootNode.addChild('Plane')
planeNode.addObject('MeshObjLoader', name='loader', filename="mesh/floorFlat.obj", triangulate="true",rotation=rotation)
planeNode.addObject('Mesh', src="@loader")
planeNode.addObject('MeshOBJLoader', name='loader', filename="mesh/floorFlat.obj", triangulate="true", rotation=rotation)
planeNode.addObject('MeshTopology', src="@loader")
planeNode.addObject('MechanicalObject', src="@loader", rotation="0 0 0", translation="0 0 0", scale="1")
planeNode.addObject('TriangleCollisionModel',simulated="0", moving="0",group="1",name='TriPlane')
planeNode.addObject('LineCollisionModel',simulated="0", moving="0",group="1")
planeNode.addObject('PointCollisionModel',simulated="0", moving="0",group="1")
planeNode.addObject('OglModel',name="Visual", fileMesh="mesh/floorFlat.obj", color="1 0 0 1",rotation=rotation, translation="0 0 0", scale="1")
planeNode.addObject('UncoupledConstraintCorrection')
planeNode.addObject('OglModel',name="Visual", src="@loader", color="1 0 0 1", rotation=rotation, translation="0 0 0", scale="1")

return rootNode
2 changes: 1 addition & 1 deletion examples/organs/liver/liverFine_gravity.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

meshPath = os.path.dirname(os.path.abspath(__file__))+'/mesh/'

plugins=["SofaPython3","SoftRobots","ModelOrderReduction","STLIB",
plugins=["SofaPython3","ModelOrderReduction","STLIB",

"Sofa.Component.Visual",
"Sofa.Component.AnimationLoop",
Expand Down
2 changes: 1 addition & 1 deletion examples/organs/liver/liverFine_rotationalActuation.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

meshPath = os.path.dirname(os.path.abspath(__file__))+'/mesh/'

plugins=["SofaPython3","SoftRobots","ModelOrderReduction","STLIB",
plugins=["SofaPython3","ModelOrderReduction","STLIB",

"Sofa.Component.Visual",
"Sofa.Component.AnimationLoop",
Expand Down
2 changes: 1 addition & 1 deletion examples/organs/liver/reduced/liver/debug/debug_scene.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
slash = "\\"

# Our Original Scene IMPORT
originalScene = os.path.dirname(os.path.abspath(__file__)) + "/../../../liverFine.pyscn"
originalScene = os.path.dirname(os.path.abspath(__file__)) + "/../../../liverFine_gravity.py"
originalScene = os.path.normpath(originalScene)
originalScene = imp.load_source(originalScene.split(slash)[-1], originalScene)

Expand Down
2 changes: 1 addition & 1 deletion examples/organs/liver/reduced/liver/reduced_liverFine.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ def Reduced_test(
def createScene(rootNode):
surfaceMeshFileName = False

MainHeader(rootNode,plugins=["SoftRobots","ModelOrderReduction"],
MainHeader(rootNode,plugins=["ModelOrderReduction"],
dt=0.01,
gravity=[0.0, -981.0, 0.0])
rootNode.VisualStyle.displayFlags="showForceFields"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ def Reduced_test(
def createScene(rootNode):
surfaceMeshFileName = False

MainHeader(rootNode,plugins=["SoftRobots","ModelOrderReduction"],
MainHeader(rootNode,plugins=["ModelOrderReduction"],
dt=0.01,
gravity=[0.0, -981.0, 0.0])
rootNode.VisualStyle.displayFlags="showForceFields"
Expand Down
1 change: 0 additions & 1 deletion examples/others/caduceus/caduceusNG.pyscn
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ def createScene(rootNode):
rootNode.addObject('VisualStyle', displayFlags='showBehaviorModels showForceFields')

rootNode.addObject('RequiredPlugin', name='ModelOrderReduction')
rootNode.addObject('RequiredPlugin', name='SoftRobots')
rootNode.addObject('RequiredPlugin', name='Sofa.Component.AnimationLoop') # Needed to use components [FreeMotionAnimationLoop]
rootNode.addObject('RequiredPlugin', name='Sofa.Component.Collision.Detection.Algorithm') # Needed to use components [BVHNarrowPhase,BruteForceBroadPhase,CollisionPipeline]
rootNode.addObject('RequiredPlugin', name='Sofa.Component.Collision.Detection.Intersection') # Needed to use components [LocalMinDistance]
Expand Down
40 changes: 39 additions & 1 deletion examples/others/caduceus/reduced/reduced_caduceusNG.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,36 @@ def Reduced_test(
VisualEye.addObject('OglModel' , name = 'VisualEye', src = '@loader', translation = [0, 5, 0])
VisualEye.addObject('BarycentricMapping')


base = modelRoot.addChild("base")

stick = base.addChild("stick")
stick.addObject('MeshOBJLoader',name="loader", filename="mesh/collision_batons.obj")
stick.addObject('MeshTopology', src='@loader', name='topo')
stick.addObject('MechanicalObject', name='stickCollisModel')
stick.addObject('LineCollisionModel',simulated="false", moving="false")
stick.addObject('PointCollisionModel',simulated="false", moving="false")

blobs = base.addChild("blobs")
blobs.addObject('MeshOBJLoader',name="loader", filename="mesh/collision_boules_V3.obj")
blobs.addObject('MeshTopology', src='@loader', name='topo')
blobs.addObject('MechanicalObject', name='blobsCollisModel')
blobs.addObject('TriangleCollisionModel',simulated="false", moving="false")
blobs.addObject('LineCollisionModel',simulated="false", moving="false")
blobs.addObject('PointCollisionModel',simulated="false", moving="false")

foot = base.addChild("foot")
foot.addObject('MeshOBJLoader',name="loader", filename="mesh/collision_pied.obj")
foot.addObject('MeshTopology', src='@loader', name='topo')
foot.addObject('MechanicalObject', name='footCollisModel')
foot.addObject('TriangleCollisionModel',simulated="false", moving="false")
foot.addObject('LineCollisionModel',simulated="false", moving="false")
foot.addObject('PointCollisionModel',simulated="false", moving="false")

visu = base.addChild("visu")
visu.addObject('MeshOBJLoader', name="SOFA_pod", filename="mesh/SOFA_pod.obj", handleSeams="1" )
visu.addObject('OglModel' , src = '@SOFA_pod', name = 'VisuPOD',color=[1,69.0/255.0,0])

return Snake


Expand All @@ -114,11 +144,19 @@ def Reduced_test(
def createScene(rootNode):
surfaceMeshFileName = False

MainHeader(rootNode,plugins=["SoftRobots","ModelOrderReduction"],
MainHeader(rootNode,plugins=["ModelOrderReduction"],
dt=0.02,
gravity=[0.0, -981.0, 0.0])
rootNode.VisualStyle.displayFlags="showForceFields"

rootNode.addObject('FreeMotionAnimationLoop')
rootNode.addObject('GenericConstraintSolver', printLog='0', tolerance="1e-6", maxIterations="500")
rootNode.addObject('CollisionPipeline', verbose="0")
rootNode.addObject('BruteForceBroadPhase', name="N2")
rootNode.addObject('BVHNarrowPhase')
rootNode.addObject('CollisionResponse', response="FrictionContactConstraint", responseParams="mu=0.7")
rootNode.addObject('LocalMinDistance', name="Proximity", alarmDistance="2.5", contactDistance="0.1", angleCone="0.05")

Reduced_test(rootNode,
name="Reduced_test",
surfaceMeshFileName=surfaceMeshFileName)
Expand Down
Loading