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()
Any suggestion is appreciated~~~