本文整理汇总了Python中Compliant.Tools.scene方法的典型用法代码示例。如果您正苦于以下问题:Python Tools.scene方法的具体用法?Python Tools.scene怎么用?Python Tools.scene使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Compliant.Tools
的用法示例。
在下文中一共展示了Tools.scene方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: createScene
# 需要导入模块: from Compliant import Tools [as 别名]
# 或者: from Compliant.Tools import scene [as 别名]
def createScene(node):
scene = Tools.scene( node )
ode = node.getObject('ode')
ode.stabilization = False
ode.warm_start = False
# ode.debug = True
# ode.propagate_lambdas = True
node.gravity = '0 0 0'
node.dt = 1e-2
num = node.createObject('MinresSolver',
name = 'num',
iterations = 100,
precision = 0)
# resp = node.createObject('DiagonalResponse')
script = node.createObject('PythonScriptController',
filename = __file__,
classname = 'Controller')
style = node.getObject('style')
style.displayFlags = 'showCollisionModels'
# parameters
mass = 1.0
stiff = 1e3
damping = 0.0
# dofs
p = insert_point(scene, 'p', [-1, 0, 0], mass)
sub = p.createChild('sub')
sub.createObject('MechanicalObject',
name = 'dofs',
position = '0 0 0')
sub.createObject('IdentityMapping',
template = 'Vec3d')
compliance = 1/stiff
sub.createObject('UniformCompliance',
template = 'Vec3d',
compliance = compliance,
damping = damping)
shared.dofs = p.getObject('dofs')
shared.mass = mass
shared.stiff = stiff
shared.damping = damping
return node
示例2: createScene
# 需要导入模块: from Compliant import Tools [as 别名]
# 或者: from Compliant.Tools import scene [as 别名]
def createScene(node):
scene = Tools.scene( node )
ode = node.getObject('ode')
ode.stabilization = "no stabilization"
# ode.warm_start = False
# ode.debug = True
node.gravity = '0 0 0'
node.dt = 1e-2
num = node.createObject('MinresSolver',
name = 'num',
iterations = 10,
precision = 0)
style = node.getObject('style')
style.displayFlags = 'showCollisionModels showBehaviorModels'
script = node.createObject('PythonScriptController',
filename = __file__,
classname = 'Controller')
mass = 1
p1 = insert_point(scene, 'p1', [-1, 1, 0], mass)
p2 = insert_point(scene, 'p2', [3, 1, 0], mass)
out = scene.createChild('out')
out.createObject('MechanicalObject',
name = 'dofs',
template = 'Vec1d',
position = '0 0 0')
alpha = 0.2
shared.alpha = alpha
matrix = vec([1 - alpha, 0, 0, alpha, 0, 0,
0, 1 - alpha, 0, 0, alpha, 0,
0, 0, 1 - alpha, 0, 0, alpha] )
value = vec([0, 0, 0])
out.createObject('AffineMultiMapping',
template = 'Vec3d,Vec1d',
input = '@../p1/dofs @../p2/dofs',
output = '@dofs',
matrix = str(matrix),
value = str(value))
out.createObject('UniformCompliance',
template = 'Vec1d',
compliance = 1e-5)
shared.p1 = p1.getObject('dofs')
shared.p2 = p2.getObject('dofs')
示例3: createScene
# 需要导入模块: from Compliant import Tools [as 别名]
# 或者: from Compliant.Tools import scene [as 别名]
def createScene(node):
scene = Tools.scene( node )
ode = node.getObject('ode')
ode.stabilization = True
ode.warm_start = False
ode.propagate_lambdas = True
# ode.debug = True
node.gravity = '0 -1 0'
num = node.createObject('SequentialSolver',
name = 'num',
iterations = 200,
precision = 0)
resp = node.createObject('DiagonalResponse')
manager = node.getObject('manager')
manager.response = 'CompliantContact'
script = node.createObject('PythonScriptController',
filename = __file__,
classname = 'Controller')
style = node.getObject('style')
style.displayFlags = 'showBehaviorModels showCollisionModels'
proximity = node.getObject('proximity')
proximity.contactDistance = 0.01
# dofs
p1 = insert_point(scene, 'p1', [-1, 1, 0])
p2 = insert_point(scene, 'p2', [1, 1, 0])
rigid = Rigid.Body('rigid')
rigid.collision = path + '/examples/mesh/ground.obj'
rigid.node = rigid.insert( scene )
ground = Rigid.Body('ground')
ground.node = ground.insert( scene )
ground.node.createObject('FixedConstraint', indices = '0')
# blocked joint between ground/rigid
joint = Rigid.Joint('joint')
joint.absolute(Rigid.Frame(), ground.node, rigid.node)
joint.node = joint.insert( scene )
shared.joint = joint
shared.body = rigid
return node
示例4: createScene
# 需要导入模块: from Compliant import Tools [as 别名]
# 或者: from Compliant.Tools import scene [as 别名]
def createScene(node):
# controller
node.createObject('PythonScriptController', filename = __file__, classname = 'Controller' )
# friction coefficient
shared.mu = float( random.randint(0,10) ) / 10.0 # a random mu in [0,1] with 0.1 step
scene = Tools.scene( node )
node.dt = 0.005
style = node.getObject('style')
style.findData('displayFlags').showMappings = True
manager = node.getObject('manager')
manager.response = 'FrictionCompliantContact'
manager.responseParams = 'mu=' + str(shared.mu) +"&horizontalConeProjection=1"
ode = node.getObject('ode')
ode.stabilization = "pre-stabilization"
num = node.createObject('SequentialSolver',
name = 'num',
iterations = 1000,
precision = 1e-20)
node.createObject('LDLTResponse')
proximity = node.getObject('proximity')
proximity.alarmDistance = 0.5
proximity.contactDistance = 0.1
# plane
plane = StructuralAPI.RigidBody( node, 'plane' )
plane.setManually( [0,0,0,0,0,0,1], 1, [1,1,1] )
plane.node.createObject('FixedConstraint')
cm = plane.addCollisionMesh( "mesh/cube.obj", [10,1,10] )
cm.addVisualModel()
# box
box = StructuralAPI.RigidBody( node, 'box' )
box.setFromMesh( 'mesh/cube.obj', 50, [0,2.5,0,0,0,0,1] )
#box.setManually( [0,2.5,0,0,0,0,1], 1, [1,1,1] )
box.dofs.showObject=True
box.dofs.showObjectScale=5
cm = box.addCollisionMesh( "mesh/cube.obj" )
cm.addVisualModel()
# keep an eye on dofs
shared.plane = plane.dofs
shared.box = box.dofs
示例5: createScene
# 需要导入模块: from Compliant import Tools [as 别名]
# 或者: from Compliant.Tools import scene [as 别名]
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 # per object friction coefficient (the friction coef between 2 objects is approximated as the product of both coefs)
manager.responseParams = 'mu='+str(globalMu)+"&horizontalConeProjection=1" # perfom an horizontal Coulomb cone projection
ode = node.getObject('ode')
ode.stabilization = "pre-stabilization"
ode.debug = False
num = node.createObject('SequentialSolver',
name = 'num',
iterations = 100,
precision = 1e-14)
node.createObject( "LDLTResponse" )
proximity = node.getObject('proximity')
proximity.alarmDistance = 0.5
proximity.contactDistance = 0.2
proximity.useLineLine = True
# plane
mesh = dir + '/../mesh/ground.obj'
plane = StructuralAPI.RigidBody( node, "plane" )
plane.setManually( [0,0,0,0,0,0,1], 1, [1,1,1] )
#body3.setFromMesh( mesh, 1 )
cm = plane.addCollisionMesh( mesh )
cm.addVisualModel()
plane.node.createObject('FixedConstraint', indices = '0')
cm.triangles.contactFriction = 0.5 # per object friction coefficient
# box
mesh = dir + '/../mesh/cube.obj'
box = StructuralAPI.RigidBody( node, "box" )
box.setFromMesh( mesh, 50, [0, 3, 0, 0,0,0,1] )
cm = box.addCollisionMesh( mesh )
cm.addVisualModel()
cm.triangles.contactFriction = 1 # per object friction coefficient
示例6: createScene
# 需要导入模块: from Compliant import Tools [as 别名]
# 或者: from Compliant.Tools import scene [as 别名]
def createScene(node):
scene = Tools.scene( node )
style = node.getObject('style')
style.findData('displayFlags').showMappings = True
manager = node.getObject('manager')
manager.response = 'FrictionCompliantContact'
manager.responseParams = 'mu=0' # per object friction coefficient (the friction coef between 2 objects is approximated as the product of both coefs)
ode = node.getObject('ode')
ode.stabilization = True
ode.debug = False
num = node.createObject('SequentialSolver',
name = 'num',
iterations = 100,
precision = 1e-14)
proximity = node.getObject('proximity')
proximity.alarmDistance = 0.5
proximity.contactDistance = 0.2
# plane
plane = Rigid.Body('plane')
plane.visual = dir + '/../mesh/ground.obj'
plane.collision = plane.visual
plane.mass_from_mesh( plane.visual, 10 )
plane.mu = 0.8 # per object friction coefficient
plane.node = plane.insert( scene )
plane.node.createObject('FixedConstraint', indices = '0')
# box
box = Rigid.Body('box')
box.visual = dir + '/../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.node = box.insert( scene )
示例7: createScene
# 需要导入模块: from Compliant import Tools [as 别名]
# 或者: from Compliant.Tools import scene [as 别名]
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)
示例8: createScene
# 需要导入模块: from Compliant import Tools [as 别名]
# 或者: from Compliant.Tools import scene [as 别名]
def createScene(node):
scene = Tools.scene( node )
ode = node.getObject('ode')
ode.stabilization = "pre-stabilization"
ode.warm_start = False
ode.propagate_lambdas = True
# ode.debug = True
node.gravity = '0 -1 0'
num = node.createObject('SequentialSolver',
name = 'num',
iterations = 200,
precision = 0,
iterateOnBilaterals = True)
resp = node.createObject('DiagonalResponse')
# NB: either iterateOnBilaterals or use a non-diagonal Response
manager = node.getObject('manager')
manager.response = 'CompliantContact'
style = node.getObject('style')
style.displayFlags = 'showBehaviorModels showCollisionModels'
proximity = node.getObject('proximity')
proximity.contactDistance = 0.01
# dofs
p1 = insert_point(scene, 'p1', [-1, 1, 0])
p2 = insert_point(scene, 'p2', [1, 1, 0])
rigid = StructuralAPI.RigidBody( scene, 'rigid' )
rigid.setManually( [0,0,0,0,0,0,1], 1, [1,1,1] )
rigid.addCollisionMesh( path + '/examples/mesh/ground.obj' )
ground = StructuralAPI.RigidBody( scene, 'ground' )
ground.setManually( [0,0,0,0,0,0,1], 1, [1,1,1] )
ground.node.createObject('FixedConstraint')
# blocked joint between ground/rigid
joint = StructuralAPI.FixedRigidJoint( "joint", ground.node, rigid.node )
script = node.createObject('PythonScriptController',
filename = __file__,
classname = 'Controller')
return node
示例9: createScene
# 需要导入模块: from Compliant import Tools [as 别名]
# 或者: from Compliant.Tools import scene [as 别名]
def createScene(node):
# controller
node.createObject('PythonScriptController',
filename = __file__,
classname = 'Controller' )
node.dt = 0.005
# friction coefficient
shared.mu = 0.5
scene = Tools.scene( node )
style = node.getObject('style')
style.findData('displayFlags').showMappings = True
manager = node.getObject('manager')
manager.response = 'FrictionCompliantContact'
manager.responseParams = 'mu=' + str(shared.mu)+"&horizontalConeProjection=1"
ode = node.getObject('ode')
node.removeObject(ode)
node.createObject('RequiredPlugin',
pluginName = 'pouf')
ode = node.createObject('pouf_solver')
num = node.createObject('pouf.pgs',
name = 'num',
iterations = 100,
homogenize = True,
precision = 1e-14)
proximity = node.getObject('proximity')
proximity.alarmDistance = 0.5
proximity.contactDistance = 0.1
# ground
ground = Rigid.Body('ground');
ground.node = ground.insert( scene );
# plane
plane = Rigid.Body('plane')
plane.visual = path + '/share/mesh/ground.obj'
plane.collision = plane.visual
plane.mass_from_mesh( plane.visual, 10 )
plane.node = plane.insert( scene )
ground.node.createObject('FixedConstraint',
indices = '0')
# ground-plane joint
frame = Rigid.Frame()
frame.translation = [8, 0, 0]
joint = Rigid.RevoluteJoint(2)
joint.absolute(frame, ground.node, plane.node)
joint.upper_limit = 0
joint.node = joint.insert( scene )
# box
box = Rigid.Body('box')
box.visual = path + '/share/mesh/cube.obj'
box.collision = box.visual
box.dofs.translation = [0, 3, 0]
box.mass_from_mesh( box.visual, 50 )
box.node = box.insert( scene )
shared.plane = plane.node.getObject('dofs')
shared.box = box.node.getObject('dofs')
shared.joint = joint.node.getObject('dofs')
# pid
shared.pid = Control.PID(shared.joint)
shared.pid.pos = -math.atan( shared.mu ) # target should trigger slide
shared.pid.basis = [0, 0, 0, 0, 0, 1]
# shared.pid.dofs.externalForce = '-1e7'
scale = 2e5
shared.pid.kp = - 5 * scale
shared.pid.kd = - 100 * scale
shared.pid.ki = - 1e-1 * scale
示例10: createScene
# 需要导入模块: from Compliant import Tools [as 别名]
# 或者: from Compliant.Tools import scene [as 别名]
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 )
示例11: createScene
# 需要导入模块: from Compliant import Tools [as 别名]
# 或者: from Compliant.Tools import scene [as 别名]
def createScene(node):
# controller
node.createObject('PythonScriptController',
filename = __file__,
classname = 'Controller' )
node.dt = 0.005
# friction coefficient
shared.mu = 0.5
scene = Tools.scene( node )
style = node.getObject('style')
style.findData('displayFlags').showMappings = True
manager = node.getObject('manager')
manager.response = 'FrictionCompliantContact'
manager.responseParams = 'mu=' + str(shared.mu)
ode = node.getObject('ode')
ode.stabilization = True
num = node.createObject('SequentialSolver',
name = 'num',
iterations = 100,
precision = 1e-14)
proximity = node.getObject('proximity')
proximity.alarmDistance = 0.5
proximity.contactDistance = 0.1
# ground
ground = Rigid.Body('ground');
ground.node = ground.insert( scene );
# plane
plane = Rigid.Body('plane')
plane.visual = dir + '/mesh/ground.obj'
plane.collision = plane.visual
plane.mass_from_mesh( plane.visual, 10 )
plane.node = plane.insert( scene )
ground.node.createObject('FixedConstraint',
indices = '0')
# ground-plane joint
frame = Rigid.Frame()
frame.translation = [5, 0, 0]
joint = Rigid.RevoluteJoint(2)
joint.absolute(frame, ground.node, plane.node)
joint.node = joint.insert( scene )
# joint limit
limit = joint.node.createChild("limit")
limit.createObject('MechanicalObject', template = 'Vec1d', position = '0')
projection = limit.createObject('ProjectionMapping', template = 'Vec6d, Vec1d' )
projection.set = '0 0 0 0 0 0 -1'
limit.createObject('UniformCompliance', template = 'Vec1d', compliance = '0' )
limit.createObject('UnilateralConstraint');
limit.createObject('Stabilization');
# box
box = Rigid.Body('box')
box.visual = dir + '/mesh/cube.obj'
box.collision = box.visual
box.dofs.translation = [0, 3, 0]
box.mass_from_mesh( box.visual, 50 )
box.node = box.insert( scene )
shared.plane = plane.node.getObject('dofs')
shared.box = box.node.getObject('dofs')
shared.joint = joint.node.getObject('dofs')
# pid
shared.pid = Control.PID(shared.joint)
shared.pid.ref_pos = -math.atan( shared.mu ) # target should trigger slide
shared.pid.basis = [0, 0, 0, 0, 0, 1]
scale = 1e6
shared.pid.kp = - 1 * scale
shared.pid.kd = - 5 * scale
shared.pid.ki = - 0.05 * scale
示例12: createScene
# 需要导入模块: from Compliant import Tools [as 别名]
# 或者: from Compliant.Tools import scene [as 别名]
def createScene(node):
# controller
node.createObject('PythonScriptController',
filename = __file__,
classname = 'Controller' )
# time step
node.dt = 0.005
# scene node
scene = Tools.scene( node )
# display flags
style = node.getObject('style')
style.findData('displayFlags').showMappings = True
# collision detection
proximity = node.getObject('proximity')
proximity.alarmDistance = 0.5
proximity.contactDistance = 0.1
# contat manager
manager = node.getObject('manager')
manager.response = 'CompliantContact'
manager.responseParams = 'compliance=0'
# integrator
ode = node.getObject('ode',)
ode.stabilization = True
ode.stabilization_damping = 0
# main solver
num = node.createObject('BenchmarkSolver', name = 'num')
response = node.createObject('LDLTResponse', name = 'response')
iterations = 300
precision = 1e-8
# we need compliantdev for qpsolver
node.createObject('RequiredPlugin',
pluginName = 'CompliantDev')
# benchmarks
shared.pgs = node.createObject('Benchmark', name = 'bench-pgs')
shared.qp = node.createObject('Benchmark', name = 'bench-qp')
# solvers
pgs = node.createObject('SequentialSolver',
name = 'pgs',
iterations = iterations,
precision = precision,
bench = '@./bench-pgs')
qp = node.createObject('QPSolver',
name = 'qp',
iterations = iterations,
precision = precision,
bench = '@./bench-qp',
schur = True)
# plane
plane = Rigid.Body('plane')
plane.visual = dir + '/mesh/ground.obj'
plane.collision = plane.visual
plane.mass_from_mesh( plane.visual, 10 )
plane.node = plane.insert( scene )
plane.node.createObject('FixedConstraint',
indices = '0')
# boxes
n_boxes = 10
for i in xrange(n_boxes):
box = Rigid.Body('box-{0}'.format(i))
box.visual = dir + '/mesh/cube.obj'
box.collision = box.visual
box.dofs.translation = [0, 2.5 * (i + 1), 0]
box.mass_from_mesh( box.visual, 50 )
box.node = box.insert( scene )