bulletphysics / bullet3

Bullet Physics SDK: real-time collision detection and multi-physics simulation for VR, games, visual effects, robotics, machine learning etc.
http://bulletphysics.org
Other
12.58k stars 2.87k forks source link

How to anchor a soft body object with another soft body object? #4235

Closed Eshaancoding closed 2 years ago

Eshaancoding commented 2 years ago

I want to anchor a soft-body cube with another soft-body cube in PyBullet. The motivation for this is one cube would act as a horizontal prismatic soft-body actuator, and the other cube would act as a vertical prismatic soft-body actuator. If we could attach these two cubes together, then it would be easy building various soft-body robots with just these primitive cubes (like this but 3 dimensional).

I tried using the createSoftBodyAnchor function to do this:

import pybullet as p
from time import sleep
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,0],planeOrn)

cubeOne = p.loadSoftBody("cube.obj", basePosition=[0,0,3], useMassSpring=1, useBendingSprings=1, springDampingAllDirections=1, mass=5, frictionCoeff=0, repulsionStiffness=0, springDampingStiffness=0, springBendingStiffness=4000, springElasticStiffness=4000, useSelfCollision=1)

cubeTwo = p.loadSoftBody("cube.obj", basePosition=[1,0,3], useMassSpring=1, useBendingSprings=1, springDampingAllDirections=1, mass=5, frictionCoeff=0, repulsionStiffness=0, springDampingStiffness=0, springBendingStiffness=4000, springElasticStiffness=4000, useSelfCollision=1)

p.createSoftBodyAnchor(cubeOne, 3, cubeTwo, -1, 2)
p.createSoftBodyAnchor(cubeOne, 1, cubeTwo, -1, 0)
p.createSoftBodyAnchor(cubeOne, 5, cubeTwo, -1, 4)
p.createSoftBodyAnchor(cubeOne, 7, cubeTwo, -1, 6) 

while p.isConnected():
  p.setGravity(0,0,gravZ)
  p.stepSimulation()
  sleep(1./240.)

However, this program doesn't work. When it runs, it acts like the soft body anchor wasn't created at all. If I replaced

cubeTwo = p.loadSoftBody("cube.obj", basePosition=[1,0,3], useMassSpring=1, useBendingSprings=1, springDampingAllDirections=1, mass=5, frictionCoeff=0, repulsionStiffness=0, springDampingStiffness=0, springBendingStiffness=4000, springElasticStiffness=4000, useSelfCollision=1)

with

cubeTwo = p.loadURDF("cube.urdf", basePosition=[1,0,3])

It would work fine. However, this means that the createSoftBodyAnchor would only work if it was anchoring a soft-body object and a rigid-body object. But how would I anchor a soft-body object with another soft-body object?

Any help would be greatly appreciated. Thanks!

erwincoumans commented 2 years ago

It hasn't been implemented, and likely won't be anytime soon (unless there is a contribution).