How to create a elastic cylinder?

Official Python bindings with a focus on reinforcement learning and robotics.
zhang_qiang
Posts: 2
Joined: Sun Mar 26, 2023 10:13 am

How to create a elastic cylinder?

Post by zhang_qiang »

Now, I can create a cylinder:

Code: Select all


import pybullet as p

physicsClient = p.connect(p.GUI)
p.setGravity(0,0,-10)

plane_shape = p.createCollisionShape(p.GEOM_PLANE)
plane_body = p.createMultiBody(baseCollisionShapeIndex=plane_shape)

cylinder = p.createCollisionShape(p.GEOM_CYLINDER, radius=0.1, height=2)
body = p.createMultiBody(baseMass=1, baseCollisionShapeIndex=cylinder,
                          basePosition=[0, 0, 1], baseOrientation=[0, 0, 0, 1])

force_magnitude = 100 
end_pos = [0.9, 0, 1] 
p.applyExternalForce(body, -1, forceObj=[force_magnitude, 0, 0], posObj=end_pos, flags=p.WORLD_FRAME)

import time
for i in range(10000):
    p.stepSimulation()
    time.sleep(1. / 240.)

p.disconnect()
And, I expect the cylinder would turn tu be a arc when the force is add on the top of cylinder. Now, the cylinder is rigid. How can I make it to be elastic?

Any suggestion is appreciated~~~