bullet3 icon indicating copy to clipboard operation
bullet3 copied to clipboard

createMultiBody for JOINT_SPHERICAL

Open unishuai opened this issue 6 months ago • 0 comments

i want to create multibody to simulate cable.And I referred to the code in the snake.py example, but unfortunately, it didn't produce any effect.i check the console ,but there are no problems.my code is here:

visualShapeId = -1 link_Masses = [] linkCollisionShapeIndices = [] linkVisualShapeIndices = [] linkPositions = [] linkOrientations = [] linkInertialFramePositions = [] linkInertialFrameOrientations = [] indices = [] jointTypes = [] axis = []

for i in range(36): link_Masses.append(5) colBallId = p.createCollisionShape(p.GEOM_CAPSULE, radius=sphereRadius, height=height) linkCollisionShapeIndices.append(colBallId) linkVisualShapeIndices.append(-1)

# basePosition = [0, i * sphereRadius * 2 + i * height, 0.1]
baseOrientation = p.getQuaternionFromEuler(baseAngle)
linkPositions.append([0, 0, sphereRadius * 2.0 +height])

linkOrientations.append([0,0,0,1])
linkInertialFramePositions.append([0, 0, 0])
linkInertialFrameOrientations.append([0, 0, 0, 1])
indices.append(i)
if i ==0:
    jointTypes.append(p.JOINT_FIXED)
else:
    jointTypes.append(p.JOINT_SPHERICAL)
axis.append([0, 0, 0])

basePosition = [0, 0, 1] baseOrientation = [0, 0, 0, 1] sphereUid = p.createMultiBody(mass, colBallId, visualShapeId, basePosition, baseOrientation, linkMasses=link_Masses, linkCollisionShapeIndices=linkCollisionShapeIndices, linkVisualShapeIndices=linkVisualShapeIndices, linkPositions=linkPositions, linkOrientations=linkOrientations, linkInertialFramePositions=linkInertialFramePositions, linkInertialFrameOrientations=linkInertialFrameOrientations, linkParentIndices=indices, linkJointTypes=jointTypes, linkJointAxis=axis, useMaximalCoordinates=useMaximalCoordinates ) cableTest.txt

it`s similar to the snake.py, but it does not work

unishuai avatar Jul 28 '24 12:07 unishuai