예제 #1
0
def createSceneReal(rootNode, dt):
    length_scale = "0.500"
    disk_msh = 'disk_'+length_scale+'.msh'
    disk_inside_stl = 'disk_inside'+length_scale+'.stl'
    
    

    
    
    
    rootNode = Scene(rootNode, gravity=[0.0, -0.0, 9.8], dt=dt)
    rootNode.createObject('RequiredPlugin', pluginName='SoftRobots')
    rootNode.createObject('VisualStyle',
                          displayFlags='showVisualModels hideBehaviorModels showCollisionModels hideBoundingCollisionModels hideForceFields showInteractionForceFields hideWireframe')


    rootNode.createObject('FreeMotionAnimationLoop')
    rootNode.createObject('GenericConstraintSolver', name='gencs', maxIterations='500', printLog='0', tolerance='0.0000001')
    rootNode.createObject('BackgroundSetting', color='0 0.168627 0.211765')
    YoungModulus = 1800
    InitialValue = 1000.0
    Translation="0 0 0"
    Bunny = ElasticMaterialObject(name="disk",
                                  attachedTo=rootNode,
                                  volumeMeshFileName=meshpath+disk_msh,
                                  surfaceMeshFileName=meshpath+disk_inside_stl,
                                  youngModulus=YoungModulus,
                                  withConstrain=True,
                                  totalMass=1.0,
                                  translation="0 0 0")
    
    fixed_const_str = ""
    fixed_const_lst = [274, 309, 344, 345, 770, 783, 807] 
    for i in fixed_const_lst:
        fixed_const_str = fixed_const_str + " " + str(i)
    
    print "Fixed stuff", fixed_const_lst, fixed_const_str

    Bunny.createObject("FixedConstraint", indices=fixed_const_str)

    cavity = PneumaticCavity(name='cavity', attachedAsAChildOf=Bunny,
                             surfaceMeshFileName=meshpath + disk_inside_stl, valueType='volumeGrowth',
                             initialValue=InitialValue, translation=Translation)

    
    BunnyVisu = Bunny.createChild('visu')
    BunnyVisu.createObject('TriangleSetTopologyContainer', name='container')
    BunnyVisu.createObject('TriangleSetTopologyModifier')
    BunnyVisu.createObject('TriangleSetTopologyAlgorithms', template='Vec3d')
    BunnyVisu.createObject('TriangleSetGeometryAlgorithms', template='Vec3d')
    BunnyVisu.createObject('Tetra2TriangleTopologicalMapping', name='Mapping', input="@../container",
                           output="@container")
    BunnyVisu.createObject('OglModel', template='ExtVec3f', color='0.3 0.2 0.2 0.6', translation=Translation)
    BunnyVisu.createObject('IdentityMapping')
    
    return Bunny
예제 #2
0
def createScene(rootNode):
    scene = Scene(rootNode, gravity=[0.0, -9810.0, 0.0])
    rootNode.dt = 0.025
    scene.VisualStyle.displayFlags = "showBehavior"

    scene.createObject("MeshSTLLoader", name="loader", filename="data/mesh/blueprint.stl")
    scene.createObject("OglModel", src="@loader")

    tripod = Tripod(rootNode)
    for arm in tripod.actuatedarms:
        arm.Constraint.BoxROI.drawBoxes = True
예제 #3
0
def createScene(rootNode):
    scene = Scene(rootNode, gravity=[0.0, -9810.0, 0.0])
    rootNode.dt = 0.025
    scene.VisualStyle.displayFlags = "showBehavior"

    scene.createObject("MeshSTLLoader",
                       name="loader",
                       filename="../data/mesh/blueprint.stl")
    scene.createObject("OglModel", src="@loader")

    tripod = Tripod(rootNode)
    for arm in tripod.actuatedarms:
        arm.Constraint.BoxROI.drawBoxes = True
예제 #4
0
def createScene(rootNode):
    scene = Scene(rootNode, gravity=[0.0, -9810, 0.0])
    scene.VisualStyle.displayFlags = "showBehavior"

    scene.createObject("MeshSTLLoader", name="loader", filename="data/mesh/blueprint.stl")
    scene.createObject("OglModel", src="@loader")

    model = scene.createChild("Model")
    tripod = Tripod(model)

    MyController(rootNode, tripod.actuatedarms)

    Interaction(rootNode, targets=[tripod.ActuatedArm0,
                                   tripod.ActuatedArm1,
                                   tripod.ActuatedArm2])
예제 #5
0
def createScene(rootNode):
    from splib.animation import animate
    from stlib.scene import Scene
    scene = Scene(rootNode)
    scene.createObject("EulerImplicitSolver")
    scene.createObject("SparseLDLSolver")
    scene.VisualStyle.displayFlags = "showBehavior"

    arm1 = ActuatedArm(scene, name="arm1", translation=[-2.0, 0.0, 0.0])
    arm1.createObject("FixedConstraint")

    def myanimate(target, factor):
        target.angle = factor

    animate(myanimate, {"target": arm1.ServoMotor},
            duration=0.5,
            mode="pingpong")
예제 #6
0
def createScene(rootNode):
    scene = Scene(rootNode, gravity=[0.0, -9810, 0.0])
    rootNode.dt = 0.025
    scene.VisualStyle.displayFlags = "showBehavior"

    scene.createObject("MeshSTLLoader", name="loader", filename="../compoz/table_stand.stl")
    scene.createObject("OglModel", src="@loader")

    # Instanciating the prefab into the graph
    body = ElasticBody(rootNode)

    # Instanciating the FixingBox prefab into the graph, constraining the mechanical object of the ElasticBody.
    fix = FixingBox(rootNode,
                    body.ElasticMaterialObject,
                    translation=[0.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
예제 #7
0
def createSceneReal(rootNode):

    #print sys.argv
    #sys.exit()
    length_scale = sys.argv[1]
    #length_scale = ""
    disk_msh = 'disk_' + length_scale + '.msh'
    disk_inside_msh = 'disk_inside' + length_scale + '.msh'

    # find point closest to zero (with positive z valu)
    vector, mid_ind = nth_smallest_point(disk_msh, 0)
    i = 0
    while vector[-1] < 0:
        i += 1
        vector, mid_ind = nth_smallest_point(disk_msh, i)

    print(vector, mid_ind)
    sys.exit()
    rootNode = Scene(rootNode, gravity=[0.0, -0.0, 0.0], dt=0.001)
    rootNode.createObject('RequiredPlugin', pluginName='SoftRobots')
    rootNode.createObject(
        'VisualStyle',
        displayFlags=
        'showVisualModels hideBehaviorModels showCollisionModels hideBoundingCollisionModels hideForceFields showInteractionForceFields hideWireframe'
    )

    rootNode.createObject('FreeMotionAnimationLoop')
    rootNode.createObject('GenericConstraintSolver',
                          maxIterations='100',
                          tolerance='0.0000001')

    # bunny
    bunny = rootNode.createChild('bunny')
    bunny.createObject('EulerImplicit', name='odesolver')
    bunny.createObject('ShewchukPCGLinearSolver',
                       iterations='15',
                       name='linearsolver',
                       tolerance='1e-5',
                       preconditioners='preconditioner',
                       use_precond='true',
                       update_step='1')

    bunny.createObject('MeshGmshLoader',
                       name='loader',
                       rotation="90 0 0",
                       filename=path + disk_msh)
    bunny.createObject('TetrahedronSetTopologyContainer',
                       src='@loader',
                       name='container')
    bunny.createObject('TetrahedronSetTopologyModifier')
    bunny.createObject('TetrahedronSetTopologyAlgorithms', template='Vec3d')
    bunny.createObject('TetrahedronSetGeometryAlgorithms', template='Vec3d')

    bunny.createObject('MechanicalObject',
                       name='tetras',
                       template='Vec3d',
                       showIndices='false',
                       showIndicesScale='4e-5',
                       rx='0',
                       dz='0')
    bunny.createObject('UniformMass', totalMass='0.5')
    bunny.createObject('TetrahedronFEMForceField',
                       template='Vec3d',
                       name='FEM',
                       method='large',
                       poissonRatio='0.3',
                       youngModulus='180')

    #bunny.createObject('BoxROI', name='boxROI', box='-3 -3 -3  3 3 3', drawBoxes='true',
    #                   position="@tetras.rest_position", tetrahedra="@container.tetrahedra")
    #bunny.createObject('RestShapeSpringsForceField', points='@boxROI.indices', stiffness='1e12')

    bunny.createObject('SparseLDLSolver', name='preconditioner')
    bunny.createObject('LinearSolverConstraintCorrection',
                       solverName='preconditioner')
    # bunny.createObject('UncoupledConstraintCorrection')

    # bunny/cavity
    cavity = bunny.createChild('cavity')
    cavity.createObject('MeshGmshLoader',
                        name='loader',
                        rotation="90 0 0",
                        filename=path + disk_inside_msh)
    cavity.createObject('Mesh', src='@loader', name='topo')
    cavity.createObject('MechanicalObject', name='cavity')
    cavity.createObject('SurfacePressureConstraint',
                        triangles='@topo.triangles',
                        value='4000',
                        valueType="1")
    cavity.createObject('BarycentricMapping',
                        name='mapping',
                        mapForces='false',
                        mapMasses='false')

    # bunny/bunnyVisu
    bunnyVisu = bunny.createChild('visu')
    bunnyVisu.createObject('TriangleSetTopologyContainer', name='container')
    bunnyVisu.createObject('TriangleSetTopologyModifier')
    bunnyVisu.createObject('TriangleSetTopologyAlgorithms', template='Vec3d')
    bunnyVisu.createObject('TriangleSetGeometryAlgorithms', template='Vec3d')
    bunnyVisu.createObject('Tetra2TriangleTopologicalMapping',
                           name='Mapping',
                           input="@../container",
                           output="@container")

    bunnyVisu.createObject('OglModel',
                           template='ExtVec3f',
                           color='0.3 0.2 0.2 0.8')
    bunnyVisu.createObject('IdentityMapping')

    #FixedBox(bunny, doVisualization=True, atPositions=BoxROICoordinates)
    #bunny.FixedBox.BoxROI.show = True
    return rootNode
예제 #8
0
def createSceneReal(rootNode, dt, fixed_const_lst, moving_const_lst):
    length_scale = sys.argv[1]
    block_msh = 'block_' + length_scale + '.msh'

    rootNode = Scene(rootNode, gravity=[0.0, -0.0, 1000.0], dt=dt)
    rootNode.createObject('RequiredPlugin', pluginName='SoftRobots')
    rootNode.createObject(
        'VisualStyle',
        displayFlags=
        'showVisualModels hideBehaviorModels showCollisionModels hideBoundingCollisionModels hideForceFields showInteractionForceFields hideWireframe'
    )

    rootNode.createObject('RequiredPlugin', pluginName='SoftRobots')
    rootNode.createObject(
        'VisualStyle',
        displayFlags=
        'showVisualModels hideBehaviorModels showCollisionModels hideBoundingCollisionModels hideForceFields showInteractionForceFields hideWireframe'
    )
    rootNode.dt = dt

    rootNode.createObject('FreeMotionAnimationLoop')
    rootNode.createObject('GenericConstraintSolver',
                          name='gencs',
                          maxIterations='500',
                          printLog='0',
                          tolerance='0.0000001')

    rootNode.createObject('BackgroundSetting', color='0 0.168627 0.211765')
    YoungModulus = 1800
    InitialValue = 0.01
    Translation = None
    Block = ElasticMaterialObject(name="block",
                                  attachedTo=rootNode,
                                  volumeMeshFileName=meshpath + block_msh,
                                  surfaceMeshFileName=None,
                                  youngModulus=YoungModulus,
                                  withConstrain=True,
                                  totalMass=1.0,
                                  translation=None)

    fixed_const_str = ""
    for i in fixed_const_lst:
        fixed_const_str = fixed_const_str + " " + str(i)

    moving_const_str = ""
    for i in moving_const_lst:
        moving_const_str = moving_const_str + " " + str(i)

    print 'moving', moving_const_str
    print 'fixed ', fixed_const_str

    Block.createObject("FixedConstraint", indices=fixed_const_str)

    inds = "7 63 62 60 5 254 240 206 236 47 68 69 253"

    Block.createObject('PartialLinearMovementConstraint',
                       indices=moving_const_str,
                       keyTimes='0 ' + str(dt) + " 10",
                       template='Vec3d',
                       movements='0. 0. 0. 0. -1 0. 0. -1 0.')
    #cavity = PneumaticCavity(name='Cavity', attachedAsAChildOf=Block,
    #                         surfaceMeshFileName=meshpath + block_inside_stl, valueType='pressureGrowth',
    #                         initialValue=InitialValue, translation=Translation)

    BlockVisu = Block.createChild('visu')
    BlockVisu.createObject('TriangleSetTopologyContainer', name='container')
    BlockVisu.createObject('TriangleSetTopologyModifier')
    BlockVisu.createObject('TriangleSetTopologyAlgorithms', template='Vec3d')
    BlockVisu.createObject('TriangleSetGeometryAlgorithms', template='Vec3d')
    BlockVisu.createObject('Tetra2TriangleTopologicalMapping',
                           name='Mapping',
                           input="@../container",
                           output="@container")
    BlockVisu.createObject('OglModel',
                           template='ExtVec3f',
                           color='0.3 0.2 0.2 0.6',
                           translation=Translation)
    BlockVisu.createObject('IdentityMapping')

    return Block
def createSceneReal(rootNode, dt, L):
    length_scale = L
    disk_msh = 'disk_' + length_scale + '.msh'
    disk_inside_stl = 'disk_inside' + length_scale + '.stl'
    '''
    # find point closest to zero (with positive z valu) 
    vector, mid_ind = point_finder.nth_smallest_point(disk_msh, 0)
    i = 0
    while vector[-1] < 1.0:
        i += 1
        vector, mid_ind = point_finder.nth_smallest_point(disk_msh, i)

    print(vector, mid_ind)'''

    rootNode = Scene(rootNode, gravity=[0.0, -0.0, 9.8], dt=dt)
    rootNode.createObject('RequiredPlugin', pluginName='SoftRobots')
    rootNode.createObject(
        'VisualStyle',
        displayFlags=
        'showVisualModels hideBehaviorModels showCollisionModels hideBoundingCollisionModels hideForceFields showInteractionForceFields hideWireframe'
    )

    rootNode.createObject('RequiredPlugin', pluginName='SoftRobots')
    rootNode.createObject(
        'VisualStyle',
        displayFlags=
        'showVisualModels hideBehaviorModels showCollisionModels hideBoundingCollisionModels hideForceFields showInteractionForceFields hideWireframe'
    )
    rootNode.dt = 0.001

    rootNode.createObject('FreeMotionAnimationLoop')
    rootNode.createObject('GenericConstraintSolver',
                          name='gencs',
                          maxIterations='500',
                          printLog='0',
                          tolerance='0.0000001')
    #disksolver = rootNode.add('SparseLDLSolver', name="solver")
    rootNode.createObject('BackgroundSetting', color='0 0.168627 0.211765')
    YoungModulus = 1800
    InitialValue = 0.01
    Translation = None
    Bunny = ElasticMaterialObject(name="disk",
                                  attachedTo=rootNode,
                                  volumeMeshFileName=meshpath + disk_msh,
                                  surfaceMeshFileName=meshpath +
                                  disk_inside_stl,
                                  youngModulus=YoungModulus,
                                  withConstrain=True,
                                  totalMass=1.0,
                                  translation=None)

    fixed_const_str = ""
    fixed_const_lst = point_finder.all_nodes_within_and_below_zero(
        disk_msh, 2.0)
    for i in fixed_const_lst:
        fixed_const_str = fixed_const_str + " " + str(i)

    print "hell", fixed_const_lst, fixed_const_str

    Bunny.createObject("FixedConstraint", indices=fixed_const_str)

    cavity = PneumaticCavity(name='Cavity',
                             attachedAsAChildOf=Bunny,
                             surfaceMeshFileName=meshpath + disk_inside_stl,
                             valueType='pressureGrowth',
                             initialValue=InitialValue,
                             translation=Translation)

    BunnyVisu = Bunny.createChild('visu')
    BunnyVisu.createObject('TriangleSetTopologyContainer', name='container')
    BunnyVisu.createObject('TriangleSetTopologyModifier')
    BunnyVisu.createObject('TriangleSetTopologyAlgorithms', template='Vec3d')
    BunnyVisu.createObject('TriangleSetGeometryAlgorithms', template='Vec3d')
    BunnyVisu.createObject('Tetra2TriangleTopologicalMapping',
                           name='Mapping',
                           input="@../container",
                           output="@container")
    BunnyVisu.createObject('OglModel',
                           template='ExtVec3f',
                           color='0.3 0.2 0.2 0.6',
                           translation=Translation)
    BunnyVisu.createObject('IdentityMapping')

    return Bunny