for a course at my university i need to do a physical simulation of a real experiment using the pybullet physics engine.
As I have already read on this forum, there seem to be trouble with the restitution values, but i couldn't find a solution.
As an example i have the following setup: A sphere with a specific restitution drops onto a plate with a restitution of 1.0.
Setting the restitution coefficient of the sphere to 1.0, i expect the sphere to bounce always back to the same height, but it bounces even higher every time.
Setting the restitution coefficient of the sphere < 1.0 i expect the following formula to be approximately correct: sqrt(bounce_height / height), but this also does not seem to apply.
Anyone have an idea what i can do or if bullet physics is not capable of my problem?
I also tried the suggestion to use "useSplitImpulse", but this option did not change anything.
Here is my test code:
Code: Select all
import pybullet as p
import time
sphereRestitution = 1.0
radius = 0.005
p.connect(p.GUI)
p.setPhysicsEngineParameter(useSplitImpulse=1)
p.setGravity(0, 0, -10)
colPlateId = p.createCollisionShape(p.GEOM_BOX, halfExtents=[0.30, 0.30, 0.05])
plateId = p.createMultiBody(baseMass=0, baseCollisionShapeIndex=colPlateId, baseVisualShapeIndex=-1, basePosition=[0,0,-0.05])
p.changeDynamics(colPlateId, -1, lateralFriction=1.0, spinningFriction=1.0, rollingFriction=1.0, linearDamping = 0, angularDamping = 0, restitution=1.0)
sphereColId = p.createCollisionShape(p.GEOM_SPHERE, radius=radius)
id = p.createMultiBody(baseMass=0.062, baseCollisionShapeIndex=sphereColId, baseVisualShapeIndex=-1, basePosition=[0,0.2,0.20])
p.changeDynamics(id, -1, lateralFriction=0.1, spinningFriction=0.1, rollingFriction=0.1,
linearDamping=0, angularDamping=0, restitution=sphereRestitution)
timestep = 0.002
p.setTimeStep(timestep)
while 1:
p.stepSimulation()
time.sleep(timestep)