From 914eabf1ad35c334841b1618989fe9211e56d618 Mon Sep 17 00:00:00 2001 From: erik pernod Date: Fri, 30 Aug 2024 15:34:45 +0200 Subject: [PATCH] [scenes] Try to fix SOFA dashboard (#138) * [scenes] Try to fix SOFA dashboard * clean liver examples * fix path for bouncingBall * Fix caduceus reduced version * Try to fix softrobots scenes... * Update reduced_diamondRobotHyperElastic.py * Update sofiaSixLegs.py * Disable sofiaSixLegs on ci, too many errors --- examples/.scene-tests | 15 +++---- examples/bouncingBall/softSphereFalling.py | 39 ++++++++++++++---- .../bouncingBall/softSphereFalling_reduced.py | 29 ++++++++------ examples/organs/liver/liverFine_gravity.py | 2 +- .../liver/liverFine_rotationalActuation.py | 2 +- .../liver/reduced/liver/debug/debug_scene.py | 2 +- .../liver/reduced/liver/reduced_liverFine.py | 2 +- .../reduced_liverFineHyperElastic.py | 2 +- examples/others/caduceus/caduceusNG.pyscn | 1 - .../caduceus/reduced/reduced_caduceusNG.py | 40 ++++++++++++++++++- .../reduced_diamondRobotHyperElastic.py | 20 +++++----- .../sofiaLeg/reduced/reduced_sofiaLeg.py | 14 +++---- .../sofiaLeg/sofiaComplete/DemoSofia.py | 10 +++-- .../controller/sofiaController.py | 4 +- .../sofiaLeg/sofiaComplete/sofiaSixLegs.py | 17 ++++---- 15 files changed, 136 insertions(+), 63 deletions(-) diff --git a/examples/.scene-tests b/examples/.scene-tests index c8acbee4..1afb18e2 100644 --- a/examples/.scene-tests +++ b/examples/.scene-tests @@ -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" @@ -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 diff --git a/examples/bouncingBall/softSphereFalling.py b/examples/bouncingBall/softSphereFalling.py index 58d62001..8b34cb85 100644 --- a/examples/bouncingBall/softSphereFalling.py +++ b/examples/bouncingBall/softSphereFalling.py @@ -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") @@ -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') @@ -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 + + \ No newline at end of file diff --git a/examples/bouncingBall/softSphereFalling_reduced.py b/examples/bouncingBall/softSphereFalling_reduced.py index dc680e60..8fd932e1 100644 --- a/examples/bouncingBall/softSphereFalling_reduced.py +++ b/examples/bouncingBall/softSphereFalling_reduced.py @@ -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] @@ -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) @@ -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) @@ -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 diff --git a/examples/organs/liver/liverFine_gravity.py b/examples/organs/liver/liverFine_gravity.py index 20db7368..b3286bfe 100644 --- a/examples/organs/liver/liverFine_gravity.py +++ b/examples/organs/liver/liverFine_gravity.py @@ -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", diff --git a/examples/organs/liver/liverFine_rotationalActuation.py b/examples/organs/liver/liverFine_rotationalActuation.py index dacb51c5..5d8fc567 100644 --- a/examples/organs/liver/liverFine_rotationalActuation.py +++ b/examples/organs/liver/liverFine_rotationalActuation.py @@ -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", diff --git a/examples/organs/liver/reduced/liver/debug/debug_scene.py b/examples/organs/liver/reduced/liver/debug/debug_scene.py index 36154313..944380e3 100644 --- a/examples/organs/liver/reduced/liver/debug/debug_scene.py +++ b/examples/organs/liver/reduced/liver/debug/debug_scene.py @@ -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) diff --git a/examples/organs/liver/reduced/liver/reduced_liverFine.py b/examples/organs/liver/reduced/liver/reduced_liverFine.py index 58b7088e..ab39d658 100644 --- a/examples/organs/liver/reduced/liver/reduced_liverFine.py +++ b/examples/organs/liver/reduced/liver/reduced_liverFine.py @@ -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" diff --git a/examples/organs/liver/reduced/liver_hyperElastic/reduced_liverFineHyperElastic.py b/examples/organs/liver/reduced/liver_hyperElastic/reduced_liverFineHyperElastic.py index 00b119ff..148134a2 100644 --- a/examples/organs/liver/reduced/liver_hyperElastic/reduced_liverFineHyperElastic.py +++ b/examples/organs/liver/reduced/liver_hyperElastic/reduced_liverFineHyperElastic.py @@ -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" diff --git a/examples/others/caduceus/caduceusNG.pyscn b/examples/others/caduceus/caduceusNG.pyscn index 4976c57e..0d49f7f3 100644 --- a/examples/others/caduceus/caduceusNG.pyscn +++ b/examples/others/caduceus/caduceusNG.pyscn @@ -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] diff --git a/examples/others/caduceus/reduced/reduced_caduceusNG.py b/examples/others/caduceus/reduced/reduced_caduceusNG.py index 79dba853..1cae53d0 100644 --- a/examples/others/caduceus/reduced/reduced_caduceusNG.py +++ b/examples/others/caduceus/reduced/reduced_caduceusNG.py @@ -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 @@ -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) diff --git a/examples/softRobots/diamond/reduced/diamond_hyperElastic/reduced_diamondRobotHyperElastic.py b/examples/softRobots/diamond/reduced/diamond_hyperElastic/reduced_diamondRobotHyperElastic.py index 5af51908..25b3ee33 100644 --- a/examples/softRobots/diamond/reduced/diamond_hyperElastic/reduced_diamondRobotHyperElastic.py +++ b/examples/softRobots/diamond/reduced/diamond_hyperElastic/reduced_diamondRobotHyperElastic.py @@ -80,31 +80,31 @@ def Reduced_test( FixedBox = modelNode.addChild('FixedBox') - FixedBox.addObject('BoxROI' , name= 'BoxROI' , orientedBox= newBox([[-15, 15, -40], [-15, -15, -40], [15, -15, -40]] , [0, 0, 35],translation,rotation,[0, 0, 25.0],scale) + multiply(scale[2],[50]).tolist(),drawBoxes=True) + FixedBox.addObject('BoxROI' , name= 'BoxROI' , orientedBox= newBox([[-15, 15, -40], [-15, -15, -40], [15, -15, -40]] , [0.0, 0.0, 35],translation,rotation,[0, 0, 25.0],scale) + multiply(scale[2],[50]).tolist(),drawBoxes=True) FixedBox.addObject('HyperReducedRestShapeSpringsForceField' , points = '@BoxROI.indices', stiffness = 1000000000000.0, name = 'reducedFF_FixedBox_1', nbModes = nbrOfModes, performECSW = hyperReduction, modesPath = path + r'/data/modes.txt', RIDPath = path + r'/data/reducedFF_FixedBox_1_RID.txt', weightsPath = path + r'/data/reducedFF_FixedBox_1_weight.txt') north = modelNode.addChild('north') - north.addObject('MechanicalObject' , position = TRSinOrigin([[0, 97, 45]] , [0, 0, 35],translation,rotation,scale), rotation = [0.0, 0.0, 0.0], translation = [0.0, 0.0, 0.0], scale = 1.0) - north.addObject('CableConstraint' , indices = [0], pullPoint = TRSinOrigin([0, 10, 30] , [0, 0, 35],translation,rotation,scale), value = 0.0, valueType = 'displacement', hasPullPoint = True) + north.addObject('MechanicalObject' , position = TRSinOrigin([[0.0, 97.0, 45.0]] , [0.0, 0.0, 35.0],translation,rotation,scale), rotation = [0.0, 0.0, 0.0], translation = [0.0, 0.0, 0.0], scale = 1.0) + north.addObject('CableConstraint' , indices = [0], pullPoint = TRSinOrigin([0, 10, 30] , [0.0, 0.0, 35.0],translation,rotation,scale), value = 0.0, valueType = 'displacement', hasPullPoint = True) north.addObject('BarycentricMapping' , name = 'Mapping', mapForces = False, mapMasses = False) west = modelNode.addChild('west') - west.addObject('MechanicalObject' , position = TRSinOrigin([[-97, 0, 45]] , [0, 0, 35],translation,rotation,scale), rotation = [0.0, 0.0, 0.0], translation = [0.0, 0.0, 0.0], scale = 1.0) - west.addObject('CableConstraint' , indices = [0], pullPoint = TRSinOrigin([-10, 0, 30] , [0, 0, 35],translation,rotation,scale), value = 0.0, valueType = 'displacement', hasPullPoint = True) + west.addObject('MechanicalObject' , position = TRSinOrigin([[-97.0, 0.0, 45.0]] , [0.0, 0.0, 35],translation,rotation,scale), rotation = [0.0, 0.0, 0.0], translation = [0.0, 0.0, 0.0], scale = 1.0) + west.addObject('CableConstraint' , indices = [0], pullPoint = TRSinOrigin([-10.0, 0.0, 30.0] , [0.0, 0.0, 35.0],translation,rotation,scale), value = 0.0, valueType = 'displacement', hasPullPoint = True) west.addObject('BarycentricMapping' , name = 'Mapping', mapForces = False, mapMasses = False) south = modelNode.addChild('south') - south.addObject('MechanicalObject' , position = TRSinOrigin([[0, -97, 45]] , [0, 0, 35],translation,rotation,scale), rotation = [0.0, 0.0, 0.0], translation = [0.0, 0.0, 0.0], scale = 1.0) - south.addObject('CableConstraint' , indices = [0], pullPoint = TRSinOrigin([0, -10, 30] , [0, 0, 35],translation,rotation,scale), value = 0.0, valueType = 'displacement', hasPullPoint = True) + south.addObject('MechanicalObject' , position = TRSinOrigin([[0.0, -97.0, 45.0]] , [0.0, 0.0, 35],translation,rotation,scale), rotation = [0.0, 0.0, 0.0], translation = [0.0, 0.0, 0.0], scale = 1.0) + south.addObject('CableConstraint' , indices = [0], pullPoint = TRSinOrigin([0.0, -10.0, 30.0] , [0.0, 0.0, 35.0],translation,rotation,scale), value = 0.0, valueType = 'displacement', hasPullPoint = True) south.addObject('BarycentricMapping' , name = 'Mapping', mapForces = False, mapMasses = False) east = modelNode.addChild('east') - east.addObject('MechanicalObject' , position = TRSinOrigin([[97, 0, 45]] , [0, 0, 35],translation,rotation,scale), rotation = [0.0, 0.0, 0.0], translation = [0.0, 0.0, 0.0], scale = 1.0) - east.addObject('CableConstraint' , indices = [0], pullPoint = TRSinOrigin([10, 0, 30] , [0, 0, 35],translation,rotation,scale), value = 0.0, valueType = 'displacement', hasPullPoint = True) + east.addObject('MechanicalObject' , position = TRSinOrigin([[97.0, 0.0, 45.0]] , [0.0, 0.0, 35],translation,rotation,scale), rotation = [0.0, 0.0, 0.0], translation = [0.0, 0.0, 0.0], scale = 1.0) + east.addObject('CableConstraint' , indices = [0], pullPoint = TRSinOrigin([10.0, 0.0, 30.0] , [0.0, 0.0, 35.0],translation,rotation,scale), value = 0.0, valueType = 'displacement', hasPullPoint = True) east.addObject('BarycentricMapping' , name = 'Mapping', mapForces = False, mapMasses = False) return modelNode @@ -122,4 +122,4 @@ def createScene(rootNode): Reduced_test(rootNode, name="Reduced_test", - surfaceMeshFileName=surfaceMeshFileName) \ No newline at end of file + surfaceMeshFileName=surfaceMeshFileName) diff --git a/examples/softRobots/sofiaLeg/reduced/reduced_sofiaLeg.py b/examples/softRobots/sofiaLeg/reduced/reduced_sofiaLeg.py index 87ec3ba4..95ada5b6 100644 --- a/examples/softRobots/sofiaLeg/reduced/reduced_sofiaLeg.py +++ b/examples/softRobots/sofiaLeg/reduced/reduced_sofiaLeg.py @@ -24,9 +24,9 @@ def newBox(positions,modelPosition,translation,rotation,offset,scale=[1.0,1.0,1. offset =transformPositions([offset],eulerRotation=rotation,scale=scale)[0] return add(pos,offset).tolist() -def Reduced_test( +def Reduced_SofiaLeg( attachedTo=None, - name="Reduced_test", + name="Reduced_SofiaLeg", rotation=[0.0, 0.0, 0.0], translation=[0.0, 0.0, 0.0], scale=[1.0, 1.0, 1.0], @@ -105,8 +105,8 @@ def createScene(rootNode): gravity=[0.0, -9810.0, 0.0]) rootNode.VisualStyle.displayFlags="showForceFields" - Reduced_test(rootNode, - name="Reduced_test", + Reduced_SofiaLeg(rootNode, + name="Reduced_SofiaLeg", surfaceMeshFileName=surfaceMeshFileName) # translate = 300 @@ -116,7 +116,7 @@ def createScene(rootNode): # for i in range(3): - # Reduced_test(rootNode, + # Reduced_SofiaLeg(rootNode, # name="Reduced_test_blue_"+str(i), # rotation=[rotationBlue*i, 0.0, 0.0], # translation=[i*translate, 0.0, 0.0], @@ -124,7 +124,7 @@ def createScene(rootNode): # surfaceMeshFileName=surfaceMeshFileName) # for i in range(3): - # Reduced_test(rootNode, + # Reduced_SofiaLeg(rootNode, # name="Reduced_test_white_"+str(i), # rotation=[0.0, rotationWhite*i, 0.0], # translation=[i*translate, translate, -translate], @@ -133,7 +133,7 @@ def createScene(rootNode): # for i in range(3): - # Reduced_test(rootNode, + # Reduced_SofiaLeg(rootNode, # name="Reduced_test_red_"+str(i), # rotation=[0.0, 0.0, i*rotationRed], # translation=[i*translate, 2*translate, -2*translate], diff --git a/examples/softRobots/sofiaLeg/sofiaComplete/DemoSofia.py b/examples/softRobots/sofiaLeg/sofiaComplete/DemoSofia.py index 8b8d6bfc..9cb4a3fa 100644 --- a/examples/softRobots/sofiaLeg/sofiaComplete/DemoSofia.py +++ b/examples/softRobots/sofiaLeg/sofiaComplete/DemoSofia.py @@ -1,5 +1,6 @@ import Sofa import os +import sys # STLIB IMPORT from stlib3.scene import MainHeader @@ -7,9 +8,10 @@ from stlib3.physics.rigid import Floor # SOFIA IMPORT -from sofia.sofiaLeg import SofiaLeg -from sofia.reduced_sofiaLeg import Reduced_SofiaLeg -from sofia.sofiaComplete import SofiaSixLegs +sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))) +from sofiaLeg import SofiaLeg +from reduced.reduced_sofiaLeg import Reduced_SofiaLeg +from sofiaSixLegs import SofiaSixLegs path = os.path.dirname(os.path.abspath(__file__)) @@ -17,7 +19,7 @@ def createScene(rootNode): - MainHeader(rootNode,plugins=["SofaPython","ModelOrderReduction"], + MainHeader(rootNode,plugins=["ModelOrderReduction"], dt=0.01, gravity=[0, -9810, 0]) rootNode.VisualStyle.displayFlags='showVisualModels' diff --git a/examples/softRobots/sofiaLeg/sofiaComplete/controller/sofiaController.py b/examples/softRobots/sofiaLeg/sofiaComplete/controller/sofiaController.py index cfce442f..9fe83e3a 100644 --- a/examples/softRobots/sofiaLeg/sofiaComplete/controller/sofiaController.py +++ b/examples/softRobots/sofiaLeg/sofiaComplete/controller/sofiaController.py @@ -13,12 +13,12 @@ def rotationPoint(Pos0, angle, brasLevier): return posOut -class SofiaController(Sofa.PythonScriptController): +class SofiaController(Sofa.Core.Controller): def initGraph(self, node): self.node = node - print self.node.name + print (self.node.name) self.name = "SofiaControlManager" def init(self,actuators,auto=True): diff --git a/examples/softRobots/sofiaLeg/sofiaComplete/sofiaSixLegs.py b/examples/softRobots/sofiaLeg/sofiaComplete/sofiaSixLegs.py index 47ffd6ee..b6e05f6d 100644 --- a/examples/softRobots/sofiaLeg/sofiaComplete/sofiaSixLegs.py +++ b/examples/softRobots/sofiaLeg/sofiaComplete/sofiaSixLegs.py @@ -5,12 +5,15 @@ from numpy import add,multiply from splib3.numerics import * + + sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))) from sofiaLeg import SofiaLeg -from reduced_sofiaLeg import Reduced_SofiaLeg +from reduced.reduced_sofiaLeg import Reduced_SofiaLeg -from controller import SofiaController +sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), './controller'))) +from sofiaController import * path = os.path.dirname(os.path.abspath(__file__)) meshPath = path + '/mesh/' @@ -103,19 +106,19 @@ def SofiaSixLegs( # Body of the robot: rigid ! BodyNode = sofia.addChild('rigidBody') BodyNode.addObject('EulerImplicitSolver', name='odesolver', firstOrder=0); - BodyNode.addObject('PCGLinearSolver', name='linearSolver',iterations=2,tolerance=1.0e-18,threshold=1.0e-30, preconditioners="preconditioner") + BodyNode.addObject('ShewchukPCGLinearSolver', name='linearSolver',iterations=2,tolerance=1.0e-18, preconditioner="@preconditioner") BodyNode.addObject('SparseLDLSolver', name='preconditioner') BodyNode.addObject('MechanicalObject', template='Rigid',name='frame1', position=rigidBodyPosition) # , showObject='1', showObjectScale=15) BodyNode.addObject('UniformMass', showAxisSizeFactor='0.01',totalMass=0.5) #mass=rigidBodyMass) # - BodyNode.addObject('LinearSolverConstraintCorrection', solverName='preconditioner'); - # BodyNode.addObject('GenericConstraintCorrection', solverName='preconditioner') + BodyNode.addObject('LinearSolverConstraintCorrection', linearSolver='@preconditioner'); + # BodyNode.addObject('GenericConstraintCorrection', linearSolver='preconditioner') # Frame FramesNode= BodyNode.addChild('frames') FramesNode.addObject('MechanicalObject', template='Rigid',name='frame1', position=framePosition, showObject='1', showObjectScale=15) # FramesNode.addObject('UniformMass', totalMass=0.05, showAxisSizeFactor=0.010) # we comment it because we don't see its use - FramesNode.addObject('RigidRigidMapping', mapMasses=0, mapForces=0) + FramesNode.addObject('RigidMapping', mapMasses=0, mapForces=0) # RigidMappedBody @@ -211,7 +214,7 @@ def createScene(rootNode): rootNode.addObject('CollisionPipeline', verbose="0"); rootNode.addObject('BruteForceBroadPhase', name="N2") rootNode.addObject('BVHNarrowPhase') - rootNode.addObject('CollisionResponse', response="FrictionContact"); + rootNode.addObject('CollisionResponse', response="FrictionContactConstraint"); rootNode.addObject('LocalMinDistance', name="Proximity", alarmDistance=10, contactDistance=1.5);