def createScene(rootNode): MainHeader(rootNode, gravity=[0.0, -981.0, 0.0]) ContactHeader(rootNode, alarmDistance=8, contactDistance=5) ShowGrid(rootNode) Floor(rootNode, translation=[0.0, -160.0, 0.0], uniformScale=5.0, isAStaticObject=True) Floor(rootNode, name="FloorObstacle", translation=[0.0, -80.0, 0.0], color=[0.0, 1.0, 0.0], uniformScale=0.8, isAStaticObject=True) for c in range(7): Cube(rootNode, name="Cube" + str(-210 + c * 70), translation=[-210 + c * 70, 0.0, 0.0], color=[c / 10.0, c * 0.7 / 10.0, 0.9], uniformScale=20.0) return rootNode
def createScene(rootNode): surfaceMeshFileName = 'liver-smoothUV.obj' MainHeader(rootNode, plugins=["SofaPython", "SoftRobots", "ModelOrderReduction"], dt=0.01, gravity=[0.0, -981, 0.0]) rootNode.createObject('FreeMotionAnimationLoop') rootNode.createObject('GenericConstraintSolver', printLog='0', tolerance="1e-6", maxIterations="500") rootNode.createObject('CollisionPipeline', verbose="0") rootNode.createObject('BruteForceBroadPhase', name="N2") rootNode.createObject('BVHNarrowPhase') rootNode.createObject('CollisionResponse', response="FrictionContact", responseParams="mu=0.7") rootNode.createObject('LocalMinDistance', name="Proximity", alarmDistance="2.5", contactDistance="0.5", angleCone="0.01") Reduced_liver(rootNode, name="Reduced_liver_blue", rotation=[0.0, 0.0, 0.0], translation=[0.0, 0.0, 0.0], surfaceColor=[0.0, 0.0, 1, 0.5], surfaceMeshFileName=surfaceMeshFileName)
def createScene(rootNode): MainHeader(rootNode, plugins=["SofaPython", "SoftRobots", "ModelOrderReduction"], dt=0.01, gravity=[0, -9810, 0], displayFlags='showVisualModels') rootNode.createObject('FreeMotionAnimationLoop') rootNode.createObject('LCPConstraintSolver', mu=str(1), tolerance="1.0e-15", maxIt="10000") rootNode.createObject('CollisionPipeline', verbose="0") rootNode.createObject('BruteForceDetection', name="N2") rootNode.createObject('CollisionResponse', response="FrictionContact") rootNode.createObject('LocalMinDistance', name="Proximity", alarmDistance=10, contactDistance=1.5) rootNode.createObject('SparseLDLSolver', name='preconditioner') Floor(rootNode, name="Plane", translation=[0, -30, 0], color=[1.0, 0.0, 1.0], isAStaticObject=True, uniformScale=10) # With reduce legs SofiaSixLegs(attachedTo=rootNode, name='sofia_reduced', reduced=True, rotation=[0, 0, 0], translation=[-200, 0, -400])
def createScene(rootNode): from stlib.scene import MainHeader from stlib.physics.deformable import ElasticMaterialObject MainHeader(rootNode) target = ElasticMaterialObject( volumeMeshFileName="mesh/liver.msh", totalMass=0.5, attachedTo=rootNode) target.createObject('BoxROI', name='boxROI', box=[-20,-20,-20,20,20,20], drawBoxes='true') SubTopology(attachedTo= target, containerLink= '@../container.position', boxRoiLink='@../boxROI.tetrahedraInROI', name='Default-tetrahedron') SubTopology(attachedTo= target, containerLink= '@../container.position', linkType= 'triangle', boxRoiLink='@../boxROI.trianglesInROI', name='Triangles') SubTopology(attachedTo= target, containerLink= '@../container.position', linkType= 'hexahedron', boxRoiLink='@../boxROI.hexahedraInROI', name='Hexahedron')
def createScene(rootNode): # main header (rootNode + gravity) MainHeader(rootNode, gravity=[0.0, -981.0, 0.0]) # contact header ContactHeader(rootNode, alarmDistance=8, contactDistance=5) # shows the grid outline ShowGrid(rootNode) # base floor Floor(rootNode, translation=[0.0, -180.0, 0.0], uniformScale=5.0, isAStaticObject=True) # obstacle floor Floor(rootNode, name="Floor Obstacle", translation=[0.0, -90.0, 0.0], color=[0.0, 1.0, 0.0], uniformScale=0.8, isAStaticObject=True) # creates 7 cubes for i in range(7): Cube(rootNode, name="Cube" + str(-210 + c * 70), translation=[-210 + c * 70, 0.0, 0.0], color=[c / 10.0, c * 0.7 / 10.0, 0.9], uniformScale=20.0) return rootNode
def createScene(rootNode): from stlib.scene import MainHeader surfaceMeshFileName = 'sofia_leg.stl' MainHeader(rootNode,plugins=["SofaPython","ModelOrderReduction"], dt=0.01, gravity=[0, -9810, 0]) SofiaLeg(rootNode, name="SofiaLeg_blue_1", rotation=[0, 0.0, 0.0], translation=[0, 0.0, 0.0], surfaceColor=[0.0, 0.0, 1, 0.5], controller={'offset':40}, surfaceMeshFileName=surfaceMeshFileName) SofiaLeg(rootNode, name="SofiaLeg_blue_2", rotation=[0, 0.0, 0.0], translation=[0, 0.0, -40.0], surfaceColor=[0.0, 1, 0, 0.5], controller={}, surfaceMeshFileName=surfaceMeshFileName) return rootNode
def createScene(rootNode): surfaceMeshFileName = 'liver-smoothUV.obj' rootNode.createObject('RequiredPlugin', name='SofaSparseSolver', pluginName='SofaSparseSolver') MainHeader(rootNode, plugins=["SofaPython", "SoftRobots", "ModelOrderReduction"], dt=0.01, gravity=[0.0, 0.0, -9810]) translate = 300 rotationBlue = 60.0 rotationWhite = 80 rotationRed = 70 Reduced_liver(rootNode, name="Reduced_liver_blue", rotation=[0.0, 0.0, 0.0], translation=[0.0, 0.0, 0.0], surfaceColor=[0.0, 0.0, 1, 0.5], surfaceMeshFileName=surfaceMeshFileName) actuator = rootNode.createChild('actuator') actuator.createObject( 'MechanicalObject', position='@../Reduced_liver_blue/liver/boxROIactuation.pointsInROI', name='actuatorState', template='Vec3d')
def createScene(rootNode): from stlib.scene import MainHeader from stlib.physics.rigid import Floor MainHeader(rootNode, plugins=["SofaPython"], dt=1., gravity=[0., -9810., 0.]) rootNode.VisualStyle.displayFlags = "showVisual showBehavior" floor = Floor(rootNode, name="Plane", color=[1., 0., 1.], isAStaticObject=True, uniformScale=10) addOrientedBoxRoi(floor, name="MyBoxRoi", position=[[50, 0, 0], [15, 15, 0], [60, 70, 25]], scale=[100, 100, 100]) myOrientedBox = getOrientedBoxFromTransform(translation=[400, 100, 100], eulerRotation=[0, 65, 0], scale=[400, 400, 800]) floor.createObject("BoxROI", orientedBox=myOrientedBox, drawBoxes=True)
def createScene(rootNode): from stlib.scene import MainHeader, ContactHeader MainHeader(rootNode, gravity=[0.0, -981.0, 0.0], plugins=["SoftRobots"]) ContactHeader(rootNode, alarmDistance=4, contactDistance=3, frictionCoef=0.08) Finger(rootNode, translation=[1.0,0.0,0.0]) return rootNode
def createScene(rootNode): surfaceMeshFileName = False rootNode.createObject('FreeMotionAnimationLoop') rootNode.createObject('GenericConstraintSolver', printLog='0', tolerance="1e-15", maxIterations="5000") rootNode.createObject('CollisionPipeline', verbose="0") rootNode.createObject('BruteForceDetection', name="N2") rootNode.createObject('RuleBasedContactManager', name="Response", response="FrictionContact", rules="0 * FrictionContact?mu=0.5") rootNode.createObject('CollisionResponse', response="FrictionContact", responseParams="mu=0.7") rootNode.createObject('LocalMinDistance', name="Proximity", alarmDistance="2.5", contactDistance="0.5", angleCone="0.01") rootNode.createObject('PythonScriptController', filename=path + "/Controller2.py", classname="controller") planeNode = rootNode.createChild('Plane') planeNode.createObject('MeshObjLoader', name='loader', filename="mesh/floorFlat.obj", triangulate="true") planeNode.createObject('Mesh', src="@loader") planeNode.createObject('MechanicalObject', src="@loader", rotation="0 0 90", translation="-5,30,30", scale="1") planeNode.createObject('Triangle', simulated="0", moving="0", group="1") planeNode.createObject('Line', simulated="0", moving="0", group="1") planeNode.createObject('Point', simulated="0", moving="0", group="1") planeNode.createObject('OglModel', name="Visual", fileMesh="mesh/floorFlat.obj", color="1 0 0 1", rotation="0 0 90", translation="0 35 -1", scale="15") planeNode.createObject('UncoupledConstraintCorrection') MainHeader(rootNode, plugins=["SofaPython", "SoftRobots", "ModelOrderReduction"], dt=0.01, gravity=[9810.0, 0.0, 0.0]) rootNode.VisualStyle.displayFlags = "showForceFields" Reduced_test(rootNode, name="Reduced_test", surfaceMeshFileName=surfaceMeshFileName)
def createScene(rootNode): from stlib.scene import MainHeader from stlib.solver import DefaultSolver MainHeader(rootNode) DefaultSolver(rootNode) Cube(rootNode, translation=[5.0,0.0,0.0]) Sphere(rootNode, translation=[-5.0,0.0,0.0]) Floor(rootNode, translation=[0.0,-1.0,0.0])
def createScene(rootNode): from stlib.scene import MainHeader from stlib.solver import DefaultSolver MainHeader(rootNode) DefaultSolver(rootNode) RigidObject(rootNode, surfaceMeshFileName="mesh/smCube27.obj", translation=[-20.0,0.0,0.0]) RigidObject(rootNode, surfaceMeshFileName="mesh/dragon.obj", translation=[ 0.0,0.0,0.0]) RigidObject(rootNode, surfaceMeshFileName="mesh/smCube27.obj", translation=[ 20.0,0.0,0.0])
def createScene(rootNode): """Setting up a simple scene""" MainHeader(rootNode, gravity=[0.0, -981.0, 0.0]) ContactHeader(rootNode, alarmDistance=5, contactDistance=1) Cube(rootNode, translation=[0.0, 60.0, 10.0], uniformScale=2.0) Floor(rootNode, translation=[0.0, -160.0, 0.0], isAStaticObject=True) Prostate = ElasticMaterialObject( rootNode, name="Prostate", volumeMeshFileName="/Users/pedro/Downloads/mac/Data/Prosta_2_2.msh", surfaceMeshFileName="/Users/pedro/Downloads/mac/Data/Prosta_2_2.stl", collisionMesh="/Users/pedro/Downloads/mac/Data/Prosta_2_2.stl", withConstrain=True, surfaceColor=[0.0, 0.70, 1.0], scale=[0.9, 0.9, 0.9], poissonRatio=0.49, youngModulus=500, translation=[10.0, 0.0, 0.0]) # Bulbo = ElasticMaterialObject(rootNode, name="Bulbo", # volumeMeshFileName="/Users/pedro/Downloads/mac/Data/Prosta_16_16.msh", # surfaceMeshFileName="/Users/pedro/Downloads/mac/Data/Prosta_16_16.stl", # collisionMesh = "/Users/pedro/Downloads/mac/Data/Prosta_16_16.stl", # withConstrain=True, # surfaceColor=[0.2, 0.9, 0.0], # scale=[0.9, 0.9, 0.9], # poissonRatio=0.49, # youngModulus=90000, # translation=[0.0,60.0,35.0]) fixingBox = [0.0, 0.0, 0.0] BoxROICoordinates = [-5, 0, -5, 5, 1, 5] FixedBox(Prostate, atPositions=[-10.0, -1.0, -20.0, 60.0, 60.0, 5.0], doVisualization=True) # scene = Scene(rootNode, gravity=[0.0, -981.0, 0.0]) # scene.dt = 0.025 # scene.VisualStyle.displayFlags = "showBehavior" # # scene.Config.createObject("MeshSTLLoader", name="loader", filename="/Users/pedro/Downloads/mac/SOFA_v19.06.99_custom_MacOS_v11/plugins/SoftRobots/docs/tutorials/Tripod/details/data/mesh/blueprint.stl") # scene.Config.createObject("OglModel", src="@loader") # body = ElasticBody(scene.Modelling) # fix = FixingBox(scene.Modelling, # body.ElasticMaterialObject, # eulerRotation=[0,0,0], # translation=[0.0, .0, 0.0], # scale=[30., 30., 30.]) # # # Changing the property of the Box ROI so that the constraint area appears on screen. # fix.BoxROI.drawBoxes = True # return rootNode
def createScene(rootNode): MainHeader(rootNode, plugins=['SofaPython', 'SoftRobots', 'SofaOpenglVisual'], gravity=[0.0, -9810, 0.0]) ContactHeader(rootNode, alarmDistance=5, contactDistance=1, frictionCoef=0.7) GripperController(rootNode) Floor(rootNode, **floorParam) Cube(rootNode, **cubeParam) # Put treshold in rigibObject construction param ? rootNode.Cube.Solver.threshold = 1e-6 for i in range(len(fingersParameters)): finger = ElasticMaterialObject( attachedTo=rootNode, volumeMeshFileName=fingersVolumeMesh, name=fingersParameters[i]['name'], rotation=fingersParameters[i]['rotation'], translation=fingersParameters[i]['translation'], surfaceMeshFileName=fingersSurfaceAndCollisionMesh, collisionMesh=fingersSurfaceAndCollisionMesh, withConstrain=True, surfaceColor=fingersColor, poissonRatio=poissonRatioFingers, youngModulus=youngModulusFingers, totalMass=fingersMass) finger.integration.rayleighStiffness = 0.1 finger.integration.rayleighMass = 0.1 finger.createObject('BoxROI', name='boxROI', box=fingersParameters[i]['ROIBox'], drawBoxes=True, doUpdate=False) finger.createObject('RestShapeSpringsForceField', points='@../finger1/boxROI.indices', stiffness=1e12, angularStiffness=1e12) PneumaticCavity(surfaceMeshFileName=fingersCavitySurfaceMesh, attachedAsAChildOf=finger, name='cavity', rotation=fingersParameters[i]['rotation'], translation=fingersParameters[i]['translation'], initialValue=cavitiesInitialValue, valueType='pressure')
def createScene(node): from stlib.scene import MainHeader from stlib.physics.deformable import ElasticMaterialObject MainHeader(node, plugins=["SoftRobots"]) target = ElasticMaterialObject(volumeMeshFileName="mesh/liver.msh", totalMass=0.5, attachedTo=node) PullingCable(target)
def createScene(rootNode): """You can load the finger only by typing runSofa finger.py""" from stlib.scene import MainHeader, ContactHeader MainHeader(rootNode, gravity=[0.0, -981.0, 0.0], plugins=["SoftRobots"]) ContactHeader(rootNode, alarmDistance=4, contactDistance=3, frictionCoef=0.08) Finger(rootNode, translation=[1.0, 0.0, 0.0]) return rootNode
def createScene(rootNode): """This is my first scene""" MainHeader(rootNode, gravity=[0.0, -981.0, 0.0]) ContactHeader(rootNode, alarmDistance=15, contactDistance=10) #ShowGrid(rootNode) Floor(rootNode, translation=[0.0, -160.0, 0.0], isAStaticObject=True) Cube(rootNode, translation=[0.0, 0.0, 0.0], uniformScale=20.0) return rootNode
def createScene(rootNode): from stlib.scene import MainHeader from stlib.physics.deformable import ElasticMaterialObject from stlib.physics.constraints import FixedBox MainHeader(rootNode) target = ElasticMaterialObject(fromVolumeMesh="mesh/liver.msh", withTotalMass=0.5, attachedTo=rootNode) FixedBox(atPositions=[-4, 0, 0, 5, 5, 4], applyTo=target, withVisualization=True)
def createScene(rootNode): from stlib.scene import MainHeader MainHeader(rootNode, gravity=" 0 0 0") ElasticMaterialObject(rootNode, "mesh/liver.msh", "NoVisual", translation=[3.0, 0.0, 0.0]) ElasticMaterialObject(rootNode, "mesh/liver.msh", "WithVisual", translation=[-3, 0, 0], surfaceMeshFileName="mesh/liver.obj", surfaceColor=[1.0, 0.0, 0.0])
def createScene(rootNode): """Setting up a simple scene""" MainHeader(rootNode, gravity=[0.0, -981.0, 0.0]) ContactHeader(rootNode, alarmDistance=15, contactDistance=5) Cube(rootNode, translation=[0.0, 60.0, 10.0], rotation=[0.0, 60.0, 10.0], uniformScale=20.0) Floor(rootNode, translation=[0.0, -160.0, 0.0], isAStaticObject=True) return rootNode
def createScene(rootNode): from stlib.scene import MainHeader from stlib.physics.deformable import ElasticMaterialObject from stlib.physics.constraints import FixedBox MainHeader(rootNode) target = ElasticMaterialObject(volumeMeshFileName="mesh/liver.msh", totalMass=0.5, attachedTo=rootNode) FixedBox(atPositions=[-4, 0, 0, 5, 5, 4], applyTo=target, doVisualization=True) CollisionMesh(surfaceMeshFileName="mesh/liver.obj", attachedTo=target)
def createScene(rootNode): from stlib.scene import MainHeader from stlib.solver import DefaultSolver MainHeader(rootNode) DefaultSolver(rootNode) RigidObject(rootNode, shapeFromFile="mesh/smCube27.obj", withTranslation=[-5.0, 0.0, 0.0]) RigidObject(rootNode, shapeFromFile="mesh/dragon.obj", withTranslation=[0.0, 0.0, 0.0]) RigidObject(rootNode, shapeFromFile="mesh/smCube27.obj", withTranslation=[5.0, 0.0, 0.0])
def createScene(rootNode): """Setting up a simple scene""" MainHeader(rootNode, gravity = [0.0, -981.0, 0.0]) ContactHeader(rootNode, alarmDistance = 5, contactDistance = 1) #cube(rootNode, translation = [10.1,60.0,10.0], uniformScale = 1.0) Floor(rootNode, translation = [0.0,-160.0,0.0], isAStaticObject = True) Prostate = ElasticMaterialObject(rootNode, name="Prostate", volumeMeshFileName="/Users/pedro/Downloads/mac/Data/Prosta_2_2.msh", surfaceMeshFileName="/Users/pedro/Downloads/mac/Data/Prosta_2_2.stl", collisionMesh = "/Users/pedro/Downloads/mac/Data/Prosta_2_2.stl", withConstrain=True, surfaceColor=[0.0, 0.70, 1.0], scale=[0.9, 0.9, 0.9], poissonRatio=0.49, youngModulus=500, translation=[10.0,0.0,0.0]) Bulbo = ElasticMaterialObject(rootNode, name="Bulbo", volumeMeshFileName="/Users/pedro/Downloads/mac/Data/needle_s.msh", surfaceMeshFileName="/Users/pedro/Downloads/mac/Data/needle_s.stl", collisionMesh = "/Users/pedro/Downloads/mac/Data/needle_s.stl", withConstrain=True, surfaceColor=[0.2, 0.9, 0.0], scale=[0.9, 0.9, 0.9], poissonRatio=0.33, youngModulus=100000, translation=[0.0,160.0,60.0], rotation=[90.0,0.0,0.0]) fixingBox=[0.0,0.0,0.0] BoxROICoordinates=[-5, 0, -5, 5, 1, 5] FixedBox(Prostate, atPositions=[-10.0,-1.0,-20.0,60.0,60.0,5.0], doVisualization=True) # fixingBox=[0.0,0.0,0.0] # BoxROICoordinates=[-5, 0, -5, 5, 1, 5] # PartiallyFixedBox(attachedTo=Bulbo, fixedAxis=[1, 0,1], box=[-10.0,140.0,-20.0,10.0,170.0,25.0], drawBoxes = True ) return rootNode
def createScene(rootNode): """ """ from stlib.scene import MainHeader from stlib.physics.deformable import ElasticMaterialObject from stlib.physics.mixedmaterial import Rigidify from splib.objectmodel import setData MainHeader(rootNode, plugins=["SofaSparseSolver"]) rootNode.VisualStyle.displayFlags = "showBehavior" modelNode = rootNode.createChild("Modeling") elasticobject = ElasticMaterialObject(modelNode, "mesh/liver.msh", "ElasticMaterialObject") # Rigidification of the elasticobject for given indices with given frameOrientations. o = Rigidify(modelNode, elasticobject, name="RigidifiedStructure", frames=[[0., 0., 0], [0., 0., 0]], groupIndices=[[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [48, 49, 50, 51]]) # Activate some rendering on the rigidified object. setData(o.RigidParts.dofs, showObject=True, showObjectScale=1, drawMode=2) setData(o.RigidParts.RigidifiedParticules.dofs, showObject=True, showObjectScale=0.1, drawMode=1, showColor=[1., 1., 0., 1.]) setData(o.DeformableParts.dofs, showObject=True, showObjectScale=0.1, drawMode=2) o.RigidParts.createObject("FixedConstraint", indices=0) simulationNode = rootNode.createChild("Simulation") simulationNode.createObject("EulerImplicitSolver") simulationNode.createObject("CGLinearSolver") simulationNode.addChild(o) return rootNode
def createScene(rootNode): surfaceMeshFileNameDiamond = 'surface.stl' surfaceMeshFileNameStrafish = 'quadriped_collision.stl' surfaceMeshFileNameSofia = 'sofia_leg.stl' MainHeader(rootNode, plugins=["SofaPython", "SoftRobots", "ModelOrderReduction"], dt=1, gravity=[0.0, -9810, 0.0]) ContactHeader(rootNode, alarmDistance=5, contactDistance=1, frictionCoef=0.7) Floor(rootNode, name="Plane", color=[1.0, 0.0, 1.0], isAStaticObject=True, uniformScale=10) Reduced_diamond(rootNode, name="Reduced_diamond_white", rotation=[-90, 0.0, 0.0], translation=[0, 50.0, 0.0], surfaceColor=[0.5, 0.5, 0.5, 0.5], surfaceMeshFileName=surfaceMeshFileNameDiamond) Reduced_starfish(rootNode, name="Reduced_starfish_red", rotation=[0, 90.0, 120.0], translation=[300, 400.0, 100.0], surfaceColor=[1, 0.0, 0.0, 0.5], surfaceMeshFileName=surfaceMeshFileNameStrafish) Reduced_SofiaLeg(rootNode, name="Reduced_sofiaLeg_blue", rotation=[0, 0.0, 0.0], translation=[-400, 60.0, 100.0], surfaceColor=[0.0, 0.0, 1, 0.5], surfaceMeshFileName=surfaceMeshFileNameSofia)
def createScene(rootNode): surfaceMeshFileName = 'surface.stl' MainHeader(rootNode, plugins=["SofaPython", "SoftRobots", "ModelOrderReduction"], dt=1, gravity=[0.0, 0.0, -9810]) translate = 300 rotationBlue = 60.0 rotationWhite = 80 rotationRed = 70 for i in range(3): Reduced_diamond(rootNode, name="Reduced_diamond_blue", rotation=[rotationBlue * i, 0.0, 0.0], translation=[i * translate, 0.0, 0.0], surfaceColor=[0.0, 0.0, 1, 0.5], surfaceMeshFileName=surfaceMeshFileName) for i in range(3): Reduced_diamond(rootNode, name="Reduced_diamond_white", rotation=[0.0, rotationWhite * i, 0.0], translation=[i * translate, translate, -translate], surfaceColor=[0.5, 0.5, 0.5, 0.5], surfaceMeshFileName=surfaceMeshFileName) for i in range(3): Reduced_diamond( rootNode, name="Reduced_diamond_red", rotation=[0.0, 0.0, i * rotationRed], translation=[i * translate, 2 * translate, -2 * translate], surfaceColor=[1, 0.0, 0.0, 0.5], surfaceMeshFileName=surfaceMeshFileName)
def createScene(rootNode): rootNode = MainHeader( rootNode, plugins=["SofaPython","SoftRobots","ModelOrderReduction"], dt=1, gravity=[0.0,0.0,-9810]) modelNode = ElasticMaterialObject( attachedTo=rootNode, volumeMeshFileName=meshPath+'siliconeV0.vtu', name='modelNode', rotation=[90, 0.0, 0.0], translation=[0.0, 0.0, 35], totalMass=0.5, withConstrain=False, # surfaceMeshFileName=meshPath+'surface.stl', # surfaceColor=[0.7, 0.7, 0.7, 0.7], poissonRatio=0.45, youngModulus=450) modelNode.createObject('GenericConstraintCorrection', solverName='Solver') # modelNode.createObject('WriteState', filename="init_myDiamondQuiteFine.vtu.state", period='0.1',writeX="0", writeX0="1", writeV="0") FixedBox( atPositions=[-15, -15, -40, 15, 15, 10], applyTo=modelNode, doVisualization=True) for i in range(len(actuatorsParam)): cable = PullingCable( attachedTo=modelNode, name=actuatorsParam[i]['withName'], cableGeometry=actuatorsParam[i]['withCableGeometry'], pullPointLocation=actuatorsParam[i]['withAPullPointLocation'], valueType="displacement") return rootNode
def createScene(rootNode): """This is my first scene""" MainHeader(rootNode, gravity=[0.0, -981.0, 0.0], plugins=["SoftRobots"]) ContactHeader(rootNode, alarmDistance=4, contactDistance=3, frictionCoef=0.08) Gripper(rootNode) Floor(rootNode, color=[1.0, 0.0, 0.0], translation=[0.0, -160.0, 0.0], isAStaticObject=True) Cube(rootNode, uniformScale=20.0, color=[1.0, 1.0, 0.0], totalMass=0.03, volume=20, inertiaMatrix=[1000.0, 0.0, 0.0, 0.0, 1000.0, 0.0, 0.0, 0.0, 1000.0], translation=[0.0, -130.0, 10.0]) return rootNode
def createScene(rootNode): from stlib.scene import MainHeader from stlib.physics.rigid import Floor MainHeader(rootNode, plugins=["SofaPython", "SoftRobots", "ModelOrderReduction"], dt=1, gravity=[0.0, -9810, 0.0]) floor = Floor(rootNode, name="Plane", color=[1.0, 0.0, 1.0], isAStaticObject=True, uniformScale=10) addOrientedBoxRoi(floor, name="MyBoxRoi", position=[[50, 0, 0], [15, 15, 0], [60, 70, 25]], scale=[100, 100, 100]) myOrientedBox = getOrientedBoxFromTransform(translation=[400, 100, 100], eulerRotation=[0, 65, 0], scale=[400, 400, 800]) floor.createObject("BoxROI", orientedBox=myOrientedBox, drawBoxes=True)
def createScene(rootNode): MainHeader(rootNode, plugins=[ "SoftRobots", "SoftRobots.Inverse", "SofaPython", "SofaSparseSolver", "SofaPreconditioner", "SofaOpenglVisual", "CosseratPlugin", "BeamAdapter", "SofaShells" ], repositoryPaths=[os.getcwd()]) rootNode.createObject( 'VisualStyle', displayFlags= 'showVisualModels hideBehaviorModels showCollisionModels hideBoundingCollisionModels hideForceFields showInteractionForceFields showWireframe' ) rootNode.createObject('FreeMotionAnimationLoop') rootNode.createObject('QPInverseProblemSolver', printLog='0') # rootNode.createObject('GenericConstraintSolver', tolerance="1e-20", maxIterations="5 00", printLog="0") rootNode.createObject('CollisionPipeline', depth="6", verbose="0", draw="1") rootNode.createObject('BruteForceDetection', name="N2") rootNode.createObject('CollisionResponse', response="FrictionContact", responseParams="mu=0.65") rootNode.createObject('LocalMinDistance', name="Proximity", alarmDistance="0.6", contactDistance="0.44", angleCone="0.01") rootNode.gravity = "0 -9180 0" rootNode.createObject('BackgroundSetting', color='0 0.168627 0.211765') rootNode.createObject('OglSceneFrame', style="Arrows", alignment="TopRight") ########################################## # Effector goal for interactive control # ########################################## goal = rootNode.createChild('goal') goal.createObject('EulerImplicitSolver', firstOrder='1') goal.createObject('CGLinearSolver', iterations='100', tolerance="1e-5", threshold="1e-5") goal.createObject('MechanicalObject', name='goalMO', position='90 3 0.35857') goal.createObject('SphereCollisionModel', radius='5') goal.createObject('UncoupledConstraintCorrection') # ############### # New adds to use the sliding Actuator ############### cableNode = rootNode.createChild('cableNode') cableNode.createObject('EulerImplicitSolver', firstOrder="0", rayleighStiffness="1.0", rayleighMass='0.1') cableNode.createObject('SparseLUSolver', name='solver') cableNode.createObject('GenericConstraintCorrection') # ############### # RigidBase ############### rigidBaseNode = cableNode.createChild('rigidBase') RigidBaseMO = rigidBaseNode.createObject('MechanicalObject', template='Rigid3d', name="RigidBaseMO", position="0 0 0 0 0 0 1", showObject='1', showObjectScale='0.1') rigidBaseNode.createObject('RestShapeSpringsForceField', name='spring', stiffness="5", angularStiffness="5", external_points="0", mstate="@RigidBaseMO", points="0", template="Rigid3d") rigidBaseNode.createObject('SlidingActuator', name="SlidingActuator0", template='Rigid3d', direction='1 0 0 0 0 0', indices=0, maxForce='100000', minForce='-30000') # rigidBaseNode.createObject('SlidingActuator', name="SlidingActuator0", template='Rigid3d', # direction='0 1 0 0 0 0', indices=0, maxForce='100000', minForce='-30000') ############### # Rate of angular Deformation (2 sections) ############### position = [ "0 0 0 " + "0 0 0 " + "0 0 0 " + "0 0 0 " + "0 0 0 " + "0 0 0 " ] longeur = '15 15 15 15 6 15' # beams size rateAngularDeformNode = cableNode.createChild('rateAngularDeform') rateAngularDeformMO = rateAngularDeformNode.createObject( 'MechanicalObject', template='Vec3d', name='rateAngularDeformMO', position=position) BeamHookeLawForce = rateAngularDeformNode.createObject( 'BeamHookeLawForceField', crossSectionShape='circular', length=longeur, radius='0.5', youngModulus='5e6') rateAngularDeformNode.createObject('SlidingActuator', name="SlidingActuator0", template='Vec3d', direction='0 1 0 ', indices=2, maxForce='100000', minForce='-30000') # rateAngularDeformNode.createObject('SlidingActuator', name="SlidingActuator0", template='Vec3d', # direction='0 1 0 ', indices=3, maxForce='100000', minForce='-30000') # rateAngularDeformNode.createObject('SlidingActuator', name="SlidingActuator0", template='Vec3d', # direction='0 1 0 ', indices=5, maxForce='100000', minForce='-30000') for i in range(1, 6): rateAngularDeformNode.createObject('SlidingActuator', name="SlidingActuator" + str(i), template='Vec3d', direction='0 1 0 ', indices=i, maxForce='100000', minForce='-30000') for i in range(1, 6): rateAngularDeformNode.createObject('SlidingActuator', name="SlidingActuator" + str(i), template='Vec3d', direction='0 0 1', indices=i, maxForce='100000', minForce='-30000') ################################ # Animation (to move the dofs) # ################################ # anim = Animation(rigidBaseNode, rateAngularDeformNode) ############## # Frames # ############## frames = [ "0.0 0 0 0 0 0 1 5 0 0 0 0 0 1 10.0 0 0 0 0 0 1 15.0 0 0 0 0 0 1 20.0 0 0 0 0 0 1" + " 30.0 0 0 0 0 0 1 35.0 0 0 0 0 0 1 40.0 0 0 0 0 0 1 45.0 0 0 0 0 0 1 55.0 0 0 0 0 0 1 60.0 0 0 0 0 0 1" + " 66.0 0 0 0 0 0 1 71.0 0 0 0 0 0 1 76.0 0 0 0 0 0 1 81.0 0 0 0 0 0 1" ] # the node of the frame needs to inherit from rigidBaseMO and rateAngularDeform mappedFrameNode = rigidBaseNode.createChild('MappedFrames') rateAngularDeformNode.addChild(mappedFrameNode) framesMO = mappedFrameNode.createObject('MechanicalObject', template='Rigid3d', name="FramesMO", position=frames, showObject='1', showObjectScale='1') # The mapping has two inputs: RigidBaseMO and rateAngularDeformMO # one output: FramesMO inputMO = rateAngularDeformMO.getLinkPath() inputMO_rigid = RigidBaseMO.getLinkPath() outputMO = framesMO.getLinkPath() curv_abs_input = '0 15 30 45 60 66 81' curv_abs_output = '0.0 5 10 15 20 30 35 40 45 55 60 66 71 76 81' mappedFrameNode.createObject('DiscretCosseratMapping', curv_abs_input=curv_abs_input, curv_abs_output=curv_abs_output, input1=inputMO, input2=inputMO_rigid, output=outputMO, debug='0') # actuators = mappedFrameNode.createChild('actuators') # actuator0 = actuators.createObject('SlidingActuator', name="SlidingActuator0", template='Rigid3d', # direction='0 0 0 1 0 0', indices=1, maxForce='100000', minForce='-30000') cable_position = [[0.0, 0.0, 0.0], [5.0, 0.0, 0.0], [10.0, 0.0, 0.0], [15.0, 0.0, 0.0], [20.0, 0.0, 0.0], [30.0, 0.0, 0.0], [35.0, 0.0, 0.0], [40.0, 0.0, 0.0], [45.0, 0.0, 0.0], [55.0, 0.0, 0.0], [60.0, 0.0, 0.0], [66.0, 0.0, 0.0], [71.0, 0.0, 0.0], [76.0, 0.0, 0.0], [81.0, 0.0, 0.0]] # This create a new node in the scene. This node is appended to the finger's node. ########################################## # Effector # ########################################## effector = mappedFrameNode.createChild('fingertip') effector.createObject('MechanicalObject', position=("89 3 0.35857")) effector.createObject('PositionEffector', template='Vec3d', indices="0", effectorGoal="@../../../../goal/goalMO.position") # effector.createObject('BarycentricMapping', mapForces="false", mapMasses="false") effector.createObject('SkinningMapping', nbRef='1', mapForces='false', mapMasses='false') # slidingPoint = mappedFrameNode.createChild('slidingPoint') # # This create a MechanicalObject, a componant holding the degree of freedom of our # # mechanical modelling. In the case of a cable it is a set of positions specifying # # the points where the cable is passing by. # slidingPointMO = slidingPoint.createObject('MechanicalObject', name="cablePos", # position=cable_position, showObject="1", showIndices="1") # slidingPoint.createObject('IdentityMapping') # mappedPointsNode = slidingPoint.createChild('MappedPoints') # femPoints.addChild(mappedPointsNode) # mappedPoints = mappedPointsNode.createObject('MechanicalObject', template='Vec3d', position=FEMpos, name="FramesMO", showObject='1', showObjectScale='1') # ## Get the tree mstate links for the mapping # inputCableMO = slidingPointMO.getLinkPath() # inputFEMCableMO = inputFEMCable.getLinkPath() # outputPointMO = mappedPoints.getLinkPath() # mappedPointsNode.createObject('CosseratActuator', nodeame="QPConstraint") # mappedPointsNode.createObject('DifferenceMultiMapping', name="pointsMulti", input1=inputFEMCableMO, input2=inputCableMO, output=outputPointMO) ########################################## # Cochlea # ########################################## cochleaNode = rootNode.createChild('cochleaNode') cochleaNode.createObject( 'MeshObjLoader', name='loader', filename='mesh/cochleeCompleteTroueeSimpleOrientationMegaTrou.obj', flipNormals="false", scale3d="10 10 10", translation="130 0 0") cochleaNode.createObject('MeshTopology', src='@loader') cochleaNode.createObject('MechanicalObject', name='dofs', template='Vec3d', showIndices='false', showIndicesScale='4e-5', rx='0', printLog="0") cochleaNode.createObject('TriangleCollisionModel', group='1') cochleaNode.createObject('LineCollisionModel', group='1') cochleaNode.createObject('PointCollisionModel', group='1') visuCochleaNode = cochleaNode.createChild('visuCochleaNode') visuCochleaNode.createObject('OglModel', name="VisualModel", color="3.0 0.5 0.0 0.9") membraneNode = rootNode.createChild('membraneNode') membraneNode.createObject('EulerImplicitSolver', rayleighStiffness='0.0', rayleighMass='0.0') membraneNode.createObject('SparseLDLSolver') membraneNode.createObject('MeshObjLoader', name='loader', filename='mesh/membraneBasilaireBetterFit.obj', flipNormals="false", scale3d="10 10 10", translation="130 0 0") membraneNode.createObject('Vertex2Frame', name="frames", template="Rigid3d.", position="@loader.position", normals="@loader.normals", invertNormals="false") #membraneNode.createObject('Mesh',src ='@loader') membraneNode.createObject('MechanicalObject', name='MO', template="Rigid3d", position="@frames.frames", showIndices="false", showIndicesScale="0.000005") membraneNode.createObject('TriangleSetTopologyContainer', name="coarseTopo", src="@loader") membraneNode.createObject('UniformMass', showAxisSizeFactor="0.1", totalMass="0.001") membraneNode.createObject('TriangularShellForceField', name="FEM", youngModulus="1e4", poissonRatio="0.33", rayleighStiffness="0", thickness="4.0e-1", measure="Strain (norm)") membraneNode.createObject( 'RestShapeSpringsForceField', points= "7 8 10 11 12 13 14 19 20 22 23 35 36 51 52 53 56 57 58 60 61 62 64 67 80 81 82 83 89 90 91 99 100 101 114 115 116 121 122 124 126 130 131 134 152 153 159 160 164 172 173 188 189 197 198 199 201 212 213 214 215 216 217 218 220 224 225 226 234 235 236 239 243 244 245 246 248 250 254 258 259 267 271 277 284 285 287 294 296 297 298 299 300 301 302 303 310 311 317 329 330 331 332 334 336 338 339 340 341 343 347 348 350 357 359 361 364 366 367 369 370 371 372 374 376 381 383 385 386 390 396 399 403 404 405 406 407 433 435 450 453 454 456 460 464 465 470 471 472 474 478 479 480 488 491 505 506 510 512 513 514 516 520 523 525 526 529 534 535 536 554 557 558 561 562 563 564 565 567 568 569 577 586 590 592 593 598 599 600 605 610 612 616 627 630 631 632 639 647 649 650 651 652 653 654 655 662 663 668 675 687 692 693 694 695 696 697 698", stiffness="1000000", angularStiffness="100000") membraneNode.createObject('LinearSolverConstraintCorrection') collMembraneNode = membraneNode.createChild('collMembraneNode') collMembraneNode.createObject('MechanicalObject', name="Coll_MO", template="Vec3d", src="@../loader") collMembraneNode.createObject('TriangleCollisionModel', bothSide="1", group='1') collMembraneNode.createObject('LineCollisionModel', bothSide="1", group='1') collMembraneNode.createObject('PointCollisionModel', bothSide="1", group='1') collMembraneNode.createObject('IdentityMapping', input="@../MO", output="@Coll_MO") visuMembraneNode = membraneNode.createChild('visuMembraneNode') visuMembraneNode.createObject('OglModel', name="Visual", color="red") return rootNode