Пример #1
0
def createScene(rootNode):
    from stlib3.scene import MainHeader
    from stlib3.physics.deformable import ElasticMaterialObject

    MainHeader(rootNode)

    # Tetrahedron and triangle subtopology
    target = ElasticMaterialObject(volumeMeshFileName="mesh/liver2.msh",
                                   totalMass=0.5,
                                   attachedTo=rootNode)

    target.addObject('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')
Пример #2
0
def ElasticBody(parent):
    body = parent.addChild('ElasticBody')

    e = ElasticMaterialObject(
        body,
        volumeMeshFileName='../../data/mesh/tripod_mid.gidmsh',
        translation=[0.0, 30, 0.0],
        rotation=[90, 0, 0],
        youngModulus=600,
        poissonRatio=0.45,
        totalMass=0.4)

    visual = body.addChild('Visual')
    visual.addObject('MeshSTLLoader',
                     name='loader',
                     filename='../../data/mesh/tripod_mid.stl')
    visual.addObject('OglModel',
                     name='renderer',
                     src='@loader',
                     color=[1.0, 1.0, 1.0, 0.5],
                     rotation=[90, 0, 0],
                     translation=[0, 30, 0])

    visual.addObject('BarycentricMapping',
                     input=e.dofs.getLinkPath(),
                     output=visual.renderer.getLinkPath())
    return body
Пример #3
0
def ElasticBody(parent):
    body = parent.addChild("ElasticBody")

    e = ElasticMaterialObject(
        body,
        volumeMeshFileName="../../data/mesh/tripod_mid.gidmsh",
        translation=[0.0, 30, 0.0],
        rotation=[90, 0, 0],
        youngModulus=800,
        poissonRatio=0.45,
        totalMass=0.032)

    visual = body.addChild("Visual")
    visual.addObject("MeshSTLLoader",
                     name="loader",
                     filename="../../data/mesh/tripod_mid.stl")
    visual.addObject("OglModel",
                     name="renderer",
                     src="@loader",
                     color=[1.0, 1.0, 1.0, 0.5],
                     rotation=[90, 0, 0],
                     translation=[0, 30, 0])

    visual.addObject("BarycentricMapping",
                     input=e.dofs.getLinkPath(),
                     output=visual.renderer.getLinkPath())

    CollisionMesh(e,
                  surfaceMeshFileName="../../data/mesh/tripod_low.stl",
                  name="silicone",
                  translation=[0.0, 30, 0.0],
                  rotation=[90, 0, 0],
                  collisionGroup=1)

    return body
def createScene(rootNode):

    rootNode.createObject('VisualStyle', displayFlags='showVisualModels showForceFields')

    rootNode.findData('gravity').value=[0.0,0.0,-9810];
    rootNode.findData('dt').value=1

    plugins=["SofaPython","SoftRobots","ModelOrderReduction"]
    for name in plugins:
        rootNode.createObject('RequiredPlugin', name=name, printLog=False)
        
    rootNode.createObject('OglSceneFrame', style="Arrows", alignment="TopRight")

    rootNode.createObject('FreeMotionAnimationLoop')
    rootNode.createObject('GenericConstraintSolver', tolerance="1e-6", maxIterations="1000")


    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')

    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
Пример #5
0
def createScene(node):
    from stlib3.scene import MainHeader
    from stlib3.physics.deformable import ElasticMaterialObject

    MainHeader(node, plugins=["SoftRobots"])
    target = ElasticMaterialObject(volumeMeshFileName="mesh/liver.msh",
                                   totalMass=0.5,
                                   attachedTo=node)

    PullingCable(target)
Пример #6
0
def createScene(rootNode):
    from stlib3.scene import MainHeader
    from stlib3.physics.deformable import ElasticMaterialObject
    from stlib3.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)
Пример #7
0
def createScene(rootNode):
    from stlib3.scene import MainHeader
    from stlib3.physics.deformable import ElasticMaterialObject
    from stlib3.physics.constraints import PartiallyFixedBox

    MainHeader(rootNode)
    target = ElasticMaterialObject(fromVolumeMesh="mesh/liver.msh",
                                   withTotalMass=0.5,
                                   attachedTo=rootNode)

    PartiallyFixedBox(box=[-4, 0, 0, 5, 5, 4],
                      attachedTo=target,
                      drawBoxes=True,
                      fixedAxis=[0, 1, 0])
Пример #8
0
def createScene(rootNode):
    """
        """
    from stlib3.scene import MainHeader
    from stlib3.physics.deformable import ElasticMaterialObject
    from stlib3.physics.mixedmaterial import Rigidify
    from splib3.objectmodel import setData

    MainHeader(rootNode,
               plugins=[
                   "SofaSparseSolver", "SofaImplicitOdeSolver",
                   "SofaMiscMapping", "SofaRigid", "SofaBoundaryCondition"
               ])
    rootNode.VisualStyle.displayFlags = "showBehavior"

    modelNode = rootNode.addChild("Modeling")
    elasticobject = ElasticMaterialObject(volumeMeshFileName="mesh/liver.msh",
                                          name="ElasticMaterialObject")
    modelNode.addChild(elasticobject)

    # 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.addObject("FixedConstraint", indices=0)

    simulationNode = rootNode.addChild("Simulation")
    simulationNode.addObject("EulerImplicitSolver")
    simulationNode.addObject("CGLinearSolver")
    simulationNode.addChild(o)
    return rootNode
Пример #9
0
def Finger(parentNode=None, name="Finger",
           rotation=[0.0, 0.0, 0.0], translation=[0.0, 0.0, 0.0],
           fixingBox=[0.0,0.0,0.0], pullPointLocation=[0.0,0.0,0.0], youngModulus=18000, valueType='position'):

    finger = Node(parentNode, name)
    eobject = ElasticMaterialObject(finger,
                                   volumeMeshFileName=os.path.join(templatepath, "mesh/finger.vtk"), #MISK need to change the relative file
                                   poissonRatio=0.3,
                                   youngModulus=youngModulus,
                                   totalMass=0.5,
                                   surfaceColor=[0.0, 0.8, 0.65],
                                   surfaceMeshFileName=os.path.join(templatepath, "mesh/finger.stl"),
                                   rotation=rotation,
                                   translation=translation)


    FixedBox(eobject, atPositions=fixingBox, doVisualization=True)

    cable=PullingCable(eobject,
                 "PullingCable",
                 pullPointLocation=pullPointLocation,
                 rotation=rotation,
                 translation=translation,
                 cableGeometry=loadPointListFromFile(os.path.join(templatepath, "mesh/cable.json")),
                 valueType=valueType);

    #Eulalie.C (21/09/18): this feature does not work, either fix it or remove this comment before SoftRobots v19
    #FingerController(eobject, cable, valueType) #MISK may change to vary variation based on value type

    CollisionMesh(eobject, name="CollisionMesh",
                 surfaceMeshFileName=os.path.join(templatepath, "mesh/finger.stl"),
                 rotation=rotation, translation=translation,
                 collisionGroup=[1, 2])

    CollisionMesh(eobject, name="CollisionMeshAuto1",
                 surfaceMeshFileName=os.path.join(templatepath, "mesh/fingerCollision_part1.stl"),
                 rotation=rotation, translation=translation,
                 collisionGroup=[1])

    CollisionMesh(eobject, name="CollisionMeshAuto2",
                 surfaceMeshFileName=os.path.join(templatepath, "mesh/fingerCollision_part2.stl"),
                 rotation=rotation, translation=translation,
                 collisionGroup=[2])


    return finger
Пример #10
0
def Finger(parentNode=None, name="Finger",
           rotation=[0.0, 0.0, 0.0], translation=[0.0, 0.0, 0.0],
           fixingBox=[-5.0,0.0,0.0,10.0,15.0,20.0], pullPointLocation=[0.0,0.0,0.0]):

    finger = Node(parentNode, name)
    eobject = ElasticMaterialObject(finger,
                                   volumeMeshFileName="../data/mesh/finger.vtk",
                                   poissonRatio=0.3,
                                   youngModulus=18000,
                                   totalMass=0.5,
                                   surfaceColor=[0.0, 0.8, 0.7],
                                   surfaceMeshFileName="../data/mesh/finger.stl",
                                   rotation=rotation,
                                   translation=translation)

    FixedBox(eobject.node, atPositions=fixingBox, doVisualization=True)

    cable=PullingCable(eobject.node,
                 "PullingCable",
                 pullPointLocation=pullPointLocation,
                 rotation=rotation,
                 translation=translation,
                 cableGeometry=loadPointListFromFile("../data/mesh/cable.json"));

    FingerController(eobject.node, cable)

    CollisionMesh(eobject.node, name="CollisionMesh",
                 surfaceMeshFileName="../data/mesh/finger.stl",
                 rotation=rotation, translation=translation,
                 collisionGroup=[1, 2])

    CollisionMesh(eobject.node, name="CollisionMeshAuto1",
                 surfaceMeshFileName="../data/mesh/fingerCollision_part1.stl",
                 rotation=rotation, translation=translation,
                 collisionGroup=[1])

    CollisionMesh(eobject.node, name="CollisionMeshAuto2",
                 surfaceMeshFileName="../data/mesh/fingerCollision_part2.stl",
                 rotation=rotation, translation=translation,
                 collisionGroup=[2])


    return finger