def createScene(rootNode): import math def animation(target, factor): target.angleIn = math.cos(factor * 2 * math.pi) Scene(rootNode) rootNode.dt = 0.003 rootNode.gravity = [0., -9810., 0.] rootNode.addObject('VisualStyle', displayFlags='showBehaviorModels') # Use these components on top of the scene to solve the constraint 'StopperConstraint'. rootNode.addObject('FreeMotionAnimationLoop') rootNode.addObject('GenericConstraintSolver', maxIterations=1e3, tolerance=1e-5) simulation = rootNode.addChild('Simulation') simulation.addObject('EulerImplicitSolver', rayleighStiffness=0.1, rayleighMass=0.1) simulation.addObject('CGLinearSolver', name='precond') ServoMotor(simulation, showWheel=True) animate(animation, {'target': simulation.ServoMotor}, duration=5., mode='loop') return rootNode
def creteScene(rootNode): import math def animation(target, factor): target.angle = math.cos(factor * 2 * math.pi) target.setX(math.cos(factor * 2 * math.pi)) Scene(rootNode) rootNode.dt = 0.003 rootNode.gravity = [0., -9810., 0.] rootNode.addObject("VisualStyle", displayFlags="showBehaviorModels") # Use these components on top of the scene to solve the constraint "StopperConstraint". rootNode.addObject("FreeMotionAnimationLoop") rootNode.addObject("GenericConstraintSolver", maxIterations=1e3, tolerance=1e-5) simulation = rootNode.addChild("Simulation") simulation.addObject("EulerImplicitSolver", rayleighStiffness=0.1, rayleighMass=0.1) simulation.addObject("CGLinearSolver", name="precond") servomotor = ServoMotor(simulation, showWheel=True) animate(animation, {"target": servomotor}, duration=5., mode="loop") return rootNode
def createScene(root): from stlib3.scene import Scene scene = Scene(root) scene.addSettings() scene.addModelling() scene.addSimulation() visu = VisualModel(visualMeshPath="mesh/smCube27.obj") visu.showGrid() scene.Modelling.addChild(visu)
def createScene(rootNode): from stlib3.scene import Scene scene = Scene(rootNode, gravity=[0., -9810., 0.], dt=0.025, plugins=["SofaSparseSolver"]) scene.addMainHeader() scene.VisualStyle.displayFlags = "showBehavior" tripod = scene.Modelling.addChild(Tripod()) scene.Simulation.addChild(tripod.RigidifiedStructure) motors = scene.Simulation.addChild("Motors") motors.addChild(tripod.ActuatedArm0) motors.addChild(tripod.ActuatedArm1) motors.addChild(tripod.ActuatedArm2)
def createScene(rootNode): scene = Scene(rootNode, gravity=[0.0, -9810.0, 0.0]) rootNode.dt = 0.025 scene.VisualStyle.displayFlags = "showBehavior" scene.addObject("MeshSTLLoader", name="loader", filename="../../data/mesh/blueprint.stl") scene.addObject("OglModel", src="@loader") tripod = Tripod(rootNode) for arm in tripod.actuatedarms: arm.Constraint.BoxROI.drawBoxes = True
def createScene(rootNode): from splib3.animation import animate from splib3.animation.easing import LinearRamp from splib3.scenegraph import get from stlib3.scene import MainHeader scene = Scene(rootNode) s = DefaultSolver(rootNode) # Test a assembly that also implements a KinematicMotorController # The angle of the KinematicMotorController is dynamically changed using a # animation function servomotor = ServoMotor(rootNode, translation=[2, 0, 0]) def myAnimation(motorctrl, factor): motorctrl.angle = LinearRamp(-3.14 / 2, 3.14 / 2, factor) animate(myAnimation, {"motorctrl": servomotor.node}, duration=1.0, mode="pingpong")
def createScene(rootNode): from splib3.animation import animate from stlib3.scene import Scene scene = Scene(rootNode) scene.addObject("EulerImplicitSolver") scene.addObject("SparseLDLSolver") scene.VisualStyle.displayFlags = "showBehavior" arm1 = ActuatedArm(scene, name="arm1", translation=[-2.0, 0.0, 0.0]) arm1.addObject("FixedConstraint") def myanimate(target, factor): target.angle = factor animate(myanimate, {"target": arm1.ServoMotor}, duration=0.5, mode="pingpong")
def createScene(rootNode): from splib3.animation import animate from stlib3.scene import Scene import math scene = Scene(rootNode) scene.VisualStyle.displayFlags = 'showBehavior' rootNode.dt = 0.003 rootNode.gravity = [0., -9810., 0.] simulation = rootNode.addChild('Simulation') simulation.addObject('EulerImplicitSolver', rayleighStiffness=0.1, rayleighMass=0.1) simulation.addObject('CGLinearSolver', name='precond') arm = ActuatedArm(simulation, name='ActuatedArm', translation=[0.0, 0.0, 0.0]) def myanimate(target, factor): target.angleIn = math.cos(factor * 2 * math.pi) animate(myanimate, {'target': arm.ServoMotor}, duration=5, mode='loop')