Exemple #1
0
def createScene(node):
    scene = Tools.scene( node )

    style = node.getObject('style')
    style.findData('displayFlags').showMappings = False
    style.findData('displayFlags').showVisual = False
    style.findData('displayFlags').showCollision = True    

    manager = node.getObject('manager')
    manager.response = 'PenalityCompliantContact'

    manager.responseParams="stiffness=1e5"

    node.dt = 2.5e-3
    # node.createObject('CompliantAttachButton')
                            
    ode = node.getObject('ode')
    node.removeObject(ode)
    ode = node.createObject("EulerImplicitSolver", rayleighStiffness = 0, rayleighMass = 0)
    
    num = node.createObject('CGLinearSolver',
                            name = 'num',
                            iterations = 100,
                            tolerance = 1e-7, threshold = 0)
    num.printLog = 1
    # num = node.createObject('CgSolver', name = 'num', iterations = 100, precision = 1e-7 )
    
    proximity = node.getObject('proximity')

    proximity.alarmDistance = 0.1
    proximity.contactDistance = 0
    proximity.useLineLine = True

  
    # planes
    for i in xrange(4):
        mesh = dir + '/../mesh/ground.obj'
        plane = StructuralAPI.RigidBody( node, "plane-{}".format(i) )

        g = Rigid3()

        n = np.zeros(3)
        n[:] = [0, 1, 0]

        r = Quaternion.exp( math.pi / 8 * np.array([1.0, 0.0, 0.0]))
        
        q = Quaternion.exp(i * math.pi / 2 * np.array([0.0, 1.0, 0.0]))

        g.orient = q * r
        
        plane.setManually( g, 1, [1,1,1] )
        
        #body3.setFromMesh( mesh, 1 )
        cm = plane.addCollisionMesh( mesh, [10, 1, 10] )
        cm.triangles.group = "0"
        
        cm.addVisualModel()
        plane.node.createObject('FixedConstraint', indices = '0')
        cm.triangles.contactFriction = 0.5 # per object friction coefficient
        
    # box

    particles = node.createChild('particles')
    n = 400
    dofs = particles.createObject('MechanicalObject', template = "Vec3d")

    pos = np.zeros( (n, 3) )
    vel = np.zeros( (n, 3) )    

    for i in xrange(n):
        pos[i, 1] = 2 + i / 1.5
        vel[i, 1] = -1        

    dofs.position = pos.tolist()
    dofs.velocity = vel.tolist()
    
    mass = particles.createObject('UniformMass', template = 'Vec3d')
    model = particles.createObject('SphereModel', template = 'Vec3d',
                                   selfCollision = True,
                                   radius = 0.1)
Exemple #2
0
def createScene(node):
    scene = Tools.scene(node)

    style = node.getObject('style')
    style.findData('displayFlags').showMappings = False
    style.findData('displayFlags').showVisual = False
    style.findData('displayFlags').showCollision = True

    manager = node.getObject('manager')
    manager.response = 'PenalityCompliantContact'

    manager.responseParams = "stiffness=1e5"

    node.dt = 2.5e-3
    # node.createObject('CompliantAttachButton')

    ode = node.getObject('ode')
    node.removeObject(ode)
    ode = node.createObject("EulerImplicitSolver",
                            rayleighStiffness=0,
                            rayleighMass=0)

    num = node.createObject('CGLinearSolver',
                            name='num',
                            iterations=100,
                            tolerance=1e-7,
                            threshold=0)
    num.printLog = 1
    # num = node.createObject('CgSolver', name = 'num', iterations = 100, precision = 1e-7 )

    proximity = node.getObject('proximity')

    proximity.alarmDistance = 0.1
    proximity.contactDistance = 0
    proximity.useLineLine = True

    # planes
    for i in xrange(4):
        mesh = dir + '/../mesh/ground.obj'
        plane = StructuralAPI.RigidBody(node, "plane-{}".format(i))

        g = Rigid3()

        n = np.zeros(3)
        n[:] = [0, 1, 0]

        r = Quaternion.exp(math.pi / 8 * np.array([1.0, 0.0, 0.0]))

        q = Quaternion.exp(i * math.pi / 2 * np.array([0.0, 1.0, 0.0]))

        g.orient = q * r

        plane.setManually(g, 1, [1, 1, 1])

        #body3.setFromMesh( mesh, 1 )
        cm = plane.addCollisionMesh(mesh, [10, 1, 10])
        cm.triangles.group = "0"

        cm.addVisualModel()
        plane.node.createObject('FixedConstraint', indices='0')
        cm.triangles.contactFriction = 0.5  # per object friction coefficient

    # box

    particles = node.createChild('particles')
    n = 400

    for i in xrange(n):
        p = particles.createChild('particle-{0}'.format(i))
        dofs = p.createObject('MechanicalObject', template="Vec3d")

        pos = np.zeros(3)
        vel = np.zeros(3)

        pos[1] = 2 + i / 1.5
        vel[1] = -1

        dofs.position = pos.tolist()
        dofs.velocity = vel.tolist()

        mass = p.createObject('UniformMass', template='Vec3d')
        model = p.createObject('SphereModel',
                               template='Vec3d',
                               selfCollision=True,
                               radius=0.1)
def createScene(node):
    scene = Tools.scene(node)

    style = node.getObject('style')
    style.findData('displayFlags').showMappings = True

    manager = node.getObject('manager')
    manager.response = 'FrictionCompliantContact'

    # node.createObject('CompliantAttachButton')

    globalMu = 0.7  # per object friction coefficient (the friction coef between 2 objects is approximated as the product of both coefs)

    manager.responseParams = 'mu={0}&compliance={1}&horizontalConeProjection=1'.format(
        globalMu, 1e-8)

    ode = node.getObject('ode')
    ode.stabilization = "pre-stabilization"
    ode.debug = 2

    # (un)comment these to see anisotropy issues with sequential solver
    solver = 'ModulusSolver'
    solver = 'SequentialSolver'

    num = node.createObject(solver,
                            name='num',
                            iterations=100,
                            precision=1e-14,
                            anderson=4)
    num.printLog = True

    proximity = node.getObject('proximity')

    proximity.alarmDistance = 0.5
    proximity.contactDistance = 0.2
    proximity.useLineLine = True

    # plane
    plane = Rigid.Body('plane')
    plane.dofs.translation = [0, 5, -15]

    alpha = math.pi / 5
    mu = math.tan(alpha)

    print "plane mu:", mu,
    if mu < globalMu: print '(should stick)'
    else: print '(should slide)'

    q = Quaternion.exp([alpha, 0.0, 0.0])

    plane.dofs.rotation = q
    s = 6
    plane.scale = [s, s, s]

    plane.visual = path + '/../mesh/ground.obj'
    plane.collision = plane.visual
    plane.mass_from_mesh(plane.visual, 10)
    plane.mu = 0.5  # per object friction coefficient
    plane.node = plane.insert(scene)
    plane.node.createObject('FixedConstraint', indices='0')

    # box
    box = Rigid.Body('box')
    box.visual = path + '/../mesh/cube.obj'
    box.collision = box.visual
    box.dofs.translation = [0, 3, 0]
    box.mass_from_mesh(box.visual, 50)
    box.mu = 1  # per object friction coefficient

    box.dofs.rotation = q

    box.node = box.insert(scene)
def createScene(node):
    scene = Tools.scene( node )

    style = node.getObject('style')
    style.findData('displayFlags').showMappings = True

    manager = node.getObject('manager')
    manager.response = 'FrictionCompliantContact'
    
    # node.createObject('CompliantAttachButton')
    
    
    globalMu = 0.7 # per object friction coefficient (the friction coef between 2 objects is approximated as the product of both coefs)
    
    manager.responseParams = 'mu={0}&compliance={1}&horizontalConeProjection=1'.format(globalMu,
                                                                                       1e-8)  
                            

    ode = node.getObject('ode')
    ode.stabilization = "pre-stabilization"
    ode.debug = 2


    # (un)comment these to see anisotropy issues with sequential solver
    solver = 'ModulusSolver'
    solver = 'SequentialSolver'
    
    num = node.createObject(solver,
                            name = 'num',
                            iterations = 100,
                            precision = 1e-14,
                            anderson = 4)
    num.printLog = True
    
    proximity = node.getObject('proximity')

    proximity.alarmDistance = 0.5
    proximity.contactDistance = 0.2
    proximity.useLineLine = True

  
    # plane
    plane = Rigid.Body('plane')
    plane.dofs.translation = [0, 5, -15]

    alpha = math.pi / 5
    mu = math.tan( alpha )

    print "plane mu:", mu, 
    if mu < globalMu: print '(should stick)'
    else: print '(should slide)'

    q = Quaternion.exp( [alpha, 0.0, 0.0] )

    plane.dofs.rotation = q
    s = 6
    plane.scale = [s, s, s]
    
    plane.visual = path + '/../mesh/ground.obj'
    plane.collision = plane.visual
    plane.mass_from_mesh( plane.visual, 10 )
    plane.mu = 0.5 # per object friction coefficient
    plane.node = plane.insert( scene )
    plane.node.createObject('FixedConstraint', indices = '0')

    # box
    box = Rigid.Body('box')
    box.visual = path + '/../mesh/cube.obj'
    box.collision = box.visual
    box.dofs.translation = [0, 3, 0]
    box.mass_from_mesh( box.visual, 50 )
    box.mu = 1 # per object friction coefficient

    box.dofs.rotation = q


    box.node = box.insert( scene )