physicsClient = p.connect(p.GUI) import pybullet_data p.setAdditionalSearchPath(pybullet_data.getDataPath()) p.resetSimulation(p.RESET_USE_DEFORMABLE_WORLD) gravZ=-10 p.setGravity(0, 0, gravZ) planeOrn = [0,0,0,1]#p.getQuaternionFromEuler([0.3,0,0]) planeId = p.loadURDF("plane.urdf", [0,0,-2],planeOrn) boxId = p.loadURDF("cube.urdf", [0,1,2],useMaximalCoordinates = True) clothId = p.loadSoftBody("cloth_z_up.obj", basePosition = [0,0,2], scale = 0.5, mass = 1., useNeoHookean = 0, useBendingSprings=1,useMassSpring=1, springElasticStiffness=40, springDampingStiffness=.1, springDampingAllDirections = 1, useSelfCollision = 0, frictionCoeff = .5, useFaceContact=1) p.createSoftBodyAnchor(clothId ,0,-1,-1) p.createSoftBodyAnchor(clothId ,1,-1,-1) p.createSoftBodyAnchor(clothId ,3,boxId,-1, [0.5,-0.5,0]) p.createSoftBodyAnchor(clothId ,2,boxId,-1, [-0.5,-0.5,0]) p.setPhysicsEngineParameter(sparseSdfVoxelSize=0.25) p.setRealTimeSimulation(1) while p.isConnected(): p.setGravity(0,0,gravZ) sleep(1./240.)
import pybullet as p from time import sleep physicsClient = p.connect(p.GUI) p.setGravity(0,0,-10) planeId = p.loadURDF("plane.urdf") bunnyId = p.loadSoftBody("bunny.obj") useRealTimeSimulation = 1 if (useRealTimeSimulation): p.setRealTimeSimulation(1) while 1: if (useRealTimeSimulation): p.setGravity(0,0,-10) sleep(0.01) # Time in seconds. else: p.stepSimulation()
import pybullet as p from time import sleep import pybullet_data physicsClient = p.connect(p.GUI) p.setAdditionalSearchPath(pybullet_data.getDataPath()) p.resetSimulation(p.RESET_USE_DEFORMABLE_WORLD) p.setGravity(0, 0, -10) planeOrn = [0,0,0,1]#p.getQuaternionFromEuler([0.3,0,0]) planeId = p.loadURDF("plane.urdf", [0,0,-2],planeOrn) boxId = p.loadURDF("cube.urdf", [0,3,2],useMaximalCoordinates = True) ballId = p.loadSoftBody("ball.vtk", basePosition = [0,0,-1], scale = 0.5, mass = 0.1, useNeoHookean = 1, NeoHookeanMu = 20, NeoHookeanLambda = 20, NeoHookeanDamping = 0.001, useSelfCollision = 1, frictionCoeff = .5, collisionMargin = 0.006) p.setTimeStep(0.001) p.setPhysicsEngineParameter(sparseSdfVoxelSize=0.25) p.setRealTimeSimulation(1) #logId = p.startStateLogging(p.STATE_LOGGING_PROFILE_TIMINGS, "perf.json") while p.isConnected(): p.setGravity(0,0,-10) sleep(1./240.) #p.resetSimulation() #p.stopStateLogging(logId)
import pybullet as p from time import sleep import pybullet_data physicsClient = p.connect(p.GUI) p.setAdditionalSearchPath(pybullet_data.getDataPath()) p.resetSimulation(p.RESET_USE_DEFORMABLE_WORLD) p.setGravity(0, 0, -10) planeId = p.loadURDF("plane.urdf", [0, 0, -2]) bunnyId = p.loadSoftBody("torus.vtk", useNeoHookean=1, NeoHookeanMu=60, NeoHookeanLambda=200, NeoHookeanDamping=0.01, useSelfCollision=1, frictionCoeff=0.5) p.setPhysicsEngineParameter(sparseSdfVoxelSize=0.25) p.setRealTimeSimulation(1) while p.isConnected(): p.setGravity(0, 0, -10) sleep(1. / 240.)
def startSim(): # create bodies mod1 = p.loadURDF("cube_small.urdf", [ body_length / 2 + arm_width + arm_length + 0.07, body_width / 2 - arm_width / 2, arm_height / 2 ], globalScaling=1. / sF) p.changeVisualShape(mod1, -1, rgbaColor=[1, 0, 0, 1]) mod2 = p.loadURDF("cube_small.urdf", [ body_length / 2 + arm_width + arm_length + 0.07, -body_width / 2 + arm_width / 2, arm_height / 2 ], globalScaling=1. / sF) p.changeVisualShape(mod2, -1, rgbaColor=[0, 1, 0, 1]) mod3 = p.loadURDF("cube_small.urdf", [ -arm_length - body_length / 2 - arm_width / 2 - 0.10, body_width / 2 - arm_width / 2, arm_height / 2 ], globalScaling=1. / sF) p.changeVisualShape(mod3, -1, rgbaColor=[1, 0, 1, 1]) mod4 = p.loadURDF("cube_small.urdf", [ -arm_length - body_length / 2 - arm_width / 2 - 0.10, -body_width / 2 + arm_width / 2, arm_height / 2 ], globalScaling=1. / sF) p.changeVisualShape(mod4, -1, rgbaColor=[0, 0, 1, 1]) corrFac = 0.02 bodyId = p.loadURDF("body.urdf", [0, 0, body_height], globalScaling=0.1 / sF) armId1 = p.loadSoftBody("arm_hori.obj", basePosition=[ body_length / 2 + arm_width / 2 + corrFac, body_width / 2 - arm_width / 2, arm_height / 2 ], scale=0.01 / sF, mass=1., useNeoHookean=1, useBendingSprings=1, useMassSpring=1, springElasticStiffness=121, springDampingStiffness=1, springDampingAllDirections=1, useSelfCollision=1, frictionCoeff=0, useFaceContact=1) armId2 = p.loadSoftBody("arm_hori.obj", basePosition=[ body_length / 2 + arm_width / 2 + corrFac, -body_width / 2 + arm_width / 2, arm_height / 2 ], scale=0.01 / sF, mass=1., useNeoHookean=1, useBendingSprings=1, useMassSpring=1, springElasticStiffness=121, springDampingStiffness=1, springDampingAllDirections=0, useSelfCollision=1, frictionCoeff=0.1, useFaceContact=1) armId3 = p.loadSoftBody( "arm_hori.obj", basePosition=[ -arm_length - body_length / 2 - arm_width / 2 - corrFac, body_width / 2 - arm_width / 2, arm_height / 2 ], scale=0.01 / sF, mass=1., useNeoHookean=1, useBendingSprings=1, useMassSpring=1, springElasticStiffness=121, springDampingStiffness=1, springDampingAllDirections=1, useSelfCollision=1, frictionCoeff=0, useFaceContact=1) armId4 = p.loadSoftBody( "arm_hori.obj", basePosition=[ -arm_length - body_length / 2 - arm_width / 2 - corrFac, -body_width / 2 + arm_width / 2, arm_height / 2 ], scale=0.01 / sF, mass=1., useNeoHookean=1, useBendingSprings=1, useMassSpring=1, springElasticStiffness=121, springDampingStiffness=1, springDampingAllDirections=1, useSelfCollision=1, frictionCoeff=0, useFaceContact=1) p.changeVisualShape(bodyId, -1, rgbaColor=[160 / 255, 69 / 255, 19 / 255, 1]) #p.changeVisualShape(armId1,-1,rgbaColor=[0,0,0,0.8]) #p.changeVisualShape(armId2,-1,rgbaColor=[0,0,0,0.8]) #p.changeVisualShape(armId3,-1,rgbaColor=[0,0,0,0.8]) #p.changeVisualShape(armId4,-1,rgbaColor=[0,0,0,0.8]) # attach bodies p.createSoftBodyAnchor(armId1, 7, bodyId, -1) p.createSoftBodyAnchor(armId1, 8, bodyId, -1) p.createSoftBodyAnchor(armId1, 16, bodyId, -1) p.createSoftBodyAnchor(armId1, 17, bodyId, -1) p.createSoftBodyAnchor(armId2, 7, bodyId, -1) p.createSoftBodyAnchor(armId2, 8, bodyId, -1) p.createSoftBodyAnchor(armId2, 16, bodyId, -1) p.createSoftBodyAnchor(armId2, 17, bodyId, -1) p.createSoftBodyAnchor(armId3, 0, bodyId, -1) p.createSoftBodyAnchor(armId3, 1, bodyId, -1) p.createSoftBodyAnchor(armId3, 2, bodyId, -1) p.createSoftBodyAnchor(armId3, 3, bodyId, -1) p.createSoftBodyAnchor(armId4, 0, bodyId, -1) p.createSoftBodyAnchor(armId4, 1, bodyId, -1) p.createSoftBodyAnchor(armId4, 2, bodyId, -1) p.createSoftBodyAnchor(armId4, 3, bodyId, -1) p.createSoftBodyAnchor(armId1, 0, mod1, -1) p.createSoftBodyAnchor(armId1, 1, mod1, -1) p.createSoftBodyAnchor(armId1, 2, mod1, -1) p.createSoftBodyAnchor(armId1, 3, mod1, -1) p.createSoftBodyAnchor(armId2, 0, mod2, -1) p.createSoftBodyAnchor(armId2, 1, mod2, -1) p.createSoftBodyAnchor(armId2, 2, mod2, -1) p.createSoftBodyAnchor(armId2, 3, mod2, -1) p.createSoftBodyAnchor(armId3, 7, mod3, -1) p.createSoftBodyAnchor(armId3, 8, mod3, -1) p.createSoftBodyAnchor(armId3, 16, mod3, -1) p.createSoftBodyAnchor(armId3, 17, mod3, -1) p.createSoftBodyAnchor(armId4, 7, mod4, -1) p.createSoftBodyAnchor(armId4, 8, mod4, -1) p.createSoftBodyAnchor(armId4, 16, mod4, -1) p.createSoftBodyAnchor(armId4, 17, mod4, -1) modList = [mod1, mod2, mod3, mod4] return modList, bodyId
-arm_length - body_length / 2 - arm_width / 2 - 0.75, -body_width / 2 + arm_width / 2, arm_height / 2 ], globalScaling=5) p.changeVisualShape(mod4, -1, rgbaColor=[0, 0, 1, 1]) corrFac = 0.05 bodyId = p.loadURDF("body.urdf", [0, 0, 2.5]) armId1 = p.loadSoftBody("arm_hori.obj", basePosition=[ body_length / 2 + arm_width / 2 + corrFac, body_width / 2 - arm_width / 2, arm_height / 2 ], scale=0.1, mass=1., useNeoHookean=1, useBendingSprings=1, useMassSpring=1, springElasticStiffness=121, springDampingStiffness=1, springDampingAllDirections=1, useSelfCollision=1, frictionCoeff=0.2, useFaceContact=1) armId2 = p.loadSoftBody("arm_hori.obj", basePosition=[ body_length / 2 + arm_width / 2 + corrFac, -body_width / 2 + arm_width / 2, arm_height / 2 ], scale=0.1, mass=1., useNeoHookean=1,
p.changeDynamics(botId, i, mass=0.1) p.setJointMotorControl2(bodyUniqueId=botId, jointIndex=i, controlMode=p.VELOCITY_CONTROL, targetVelocity=1, force=100) print(i, p.getJointInfo(botId, i)) #softId = p.loadSoftBody("torus.vtk", useNeoHookean = 1, NeoHookeanMu = 60, NeoHookeanLambda = 200, NeoHookeanDamping = 0.01, useSelfCollision = 1, frictionCoeff = 0.5) softId = p.loadSoftBody("tube.vtk", [0, 0, 0], mass=10, useNeoHookean=0, NeoHookeanMu=600, NeoHookeanLambda=200, NeoHookeanDamping=0.01, useSelfCollision=0, frictionCoeff=0.5, springElasticStiffness=500, springDampingStiffness=50, springBendingStiffness=50, useMassSpring=1, useBendingSprings=1, collisionMargin=0.05) # softId2 = p.loadSoftBody("tube.vtk", [0, 0, 2], mass=10, useNeoHookean = 0, NeoHookeanMu = 600, NeoHookeanLambda = 200, # NeoHookeanDamping = 0.01, useSelfCollision = 0, frictionCoeff = 0.5, # springElasticStiffness=500, springDampingStiffness=50, springBendingStiffness=50, # useMassSpring=1, useBendingSprings=1, collisionMargin=0.1) p.setPhysicsEngineParameter(sparseSdfVoxelSize=0.25) p.setRealTimeSimulation(0) np.set_printoptions(precision=4, suppress=True)
p.resetSimulation(p.RESET_USE_DEFORMABLE_WORLD) p.resetDebugVisualizerCamera(3, -420, -30, [0.3, 0.9, -2]) p.setGravity(0, 0, -10) tex = p.loadTexture("uvmap.png") planeId = p.loadURDF("plane.urdf", [0, 0, -2]) boxId = p.loadURDF("cube.urdf", [0, 3, 2], useMaximalCoordinates=True) bunnyId = p.loadSoftBody("torus/torus_textured.obj", simFileName="torus.vtk", mass=3, useNeoHookean=1, NeoHookeanMu=180, NeoHookeanLambda=600, NeoHookeanDamping=0.01, collisionMargin=0.006, useSelfCollision=1, frictionCoeff=0.5, repulsionStiffness=800) p.changeVisualShape(bunnyId, -1, rgbaColor=[1, 1, 1, 1], textureUniqueId=tex, flags=0) bunny2 = p.loadURDF("torus_deform.urdf", [0, 1, 0.2], flags=p.URDF_USE_SELF_COLLISION) p.changeVisualShape(bunny2,
import pybullet as p from time import sleep physicsClient = p.connect(p.GUI) p.setGravity(0, 0, -10) planeId = p.loadURDF("plane.urdf", [0, 0, -2]) boxId = p.loadURDF("cube.urdf", [0, 3, 2], useMaximalCoordinates=True) bunnyId = p.loadSoftBody("bunny.obj") #.obj")#.vtk") #meshData = p.getMeshData(bunnyId) #print("meshData=",meshData) #p.loadURDF("cube_small.urdf", [1, 0, 1]) useRealTimeSimulation = 1 if (useRealTimeSimulation): p.setRealTimeSimulation(1) print(p.getDynamicsInfo(planeId, -1)) #print(p.getDynamicsInfo(bunnyId, 0)) print(p.getDynamicsInfo(boxId, -1)) p.changeDynamics(boxId, -1, mass=10) while p.isConnected(): p.setGravity(0, 0, -10) if (useRealTimeSimulation): sleep(0.01) # Time in seconds. #p.getCameraImage(320,200,renderer=p.ER_BULLET_HARDWARE_OPENGL ) else: p.stepSimulation()