summaryrefslogtreecommitdiff
path: root/examples/pybullet/examples/restitution.py
diff options
context:
space:
mode:
Diffstat (limited to 'examples/pybullet/examples/restitution.py')
-rw-r--r--examples/pybullet/examples/restitution.py52
1 files changed, 26 insertions, 26 deletions
diff --git a/examples/pybullet/examples/restitution.py b/examples/pybullet/examples/restitution.py
index 3b12185a8..dc169fe48 100644
--- a/examples/pybullet/examples/restitution.py
+++ b/examples/pybullet/examples/restitution.py
@@ -5,36 +5,36 @@ import pybullet as p
import time
cid = p.connect(p.SHARED_MEMORY)
-if (cid<0):
- cid = p.connect(p.GUI)
-restitutionId = p.addUserDebugParameter("restitution",0,1,1)
-restitutionVelocityThresholdId = p.addUserDebugParameter("res. vel. threshold",0,3,0.2)
+if (cid < 0):
+ cid = p.connect(p.GUI)
+restitutionId = p.addUserDebugParameter("restitution", 0, 1, 1)
+restitutionVelocityThresholdId = p.addUserDebugParameter("res. vel. threshold", 0, 3, 0.2)
-lateralFrictionId = p.addUserDebugParameter("lateral friction",0,1,0.5)
-spinningFrictionId = p.addUserDebugParameter("spinning friction",0,1,0.03)
-rollingFrictionId = p.addUserDebugParameter("rolling friction",0,1,0.03)
+lateralFrictionId = p.addUserDebugParameter("lateral friction", 0, 1, 0.5)
+spinningFrictionId = p.addUserDebugParameter("spinning friction", 0, 1, 0.03)
+rollingFrictionId = p.addUserDebugParameter("rolling friction", 0, 1, 0.03)
plane = p.loadURDF("plane_with_restitution.urdf")
-sphere = p.loadURDF("sphere_with_restitution.urdf",[0,0,2])
+sphere = p.loadURDF("sphere_with_restitution.urdf", [0, 0, 2])
p.setRealTimeSimulation(1)
-p.setGravity(0,0,-10)
+p.setGravity(0, 0, -10)
while (1):
- restitution = p.readUserDebugParameter(restitutionId)
- restitutionVelocityThreshold = p.readUserDebugParameter(restitutionVelocityThresholdId)
- p.setPhysicsEngineParameter(restitutionVelocityThreshold=restitutionVelocityThreshold)
+ restitution = p.readUserDebugParameter(restitutionId)
+ restitutionVelocityThreshold = p.readUserDebugParameter(restitutionVelocityThresholdId)
+ p.setPhysicsEngineParameter(restitutionVelocityThreshold=restitutionVelocityThreshold)
- lateralFriction = p.readUserDebugParameter(lateralFrictionId)
- spinningFriction = p.readUserDebugParameter(spinningFrictionId)
- rollingFriction = p.readUserDebugParameter(rollingFrictionId)
- p.changeDynamics(plane,-1,lateralFriction=1)
- p.changeDynamics(sphere,-1,lateralFriction=lateralFriction)
- p.changeDynamics(sphere,-1,spinningFriction=spinningFriction)
- p.changeDynamics(sphere,-1,rollingFriction=rollingFriction)
-
- p.changeDynamics(plane,-1,restitution=restitution)
- p.changeDynamics(sphere,-1,restitution=restitution)
- pos,orn=p.getBasePositionAndOrientation(sphere)
- #print("pos=")
- #print(pos)
- time.sleep(0.01) \ No newline at end of file
+ lateralFriction = p.readUserDebugParameter(lateralFrictionId)
+ spinningFriction = p.readUserDebugParameter(spinningFrictionId)
+ rollingFriction = p.readUserDebugParameter(rollingFrictionId)
+ p.changeDynamics(plane, -1, lateralFriction=1)
+ p.changeDynamics(sphere, -1, lateralFriction=lateralFriction)
+ p.changeDynamics(sphere, -1, spinningFriction=spinningFriction)
+ p.changeDynamics(sphere, -1, rollingFriction=rollingFriction)
+
+ p.changeDynamics(plane, -1, restitution=restitution)
+ p.changeDynamics(sphere, -1, restitution=restitution)
+ pos, orn = p.getBasePositionAndOrientation(sphere)
+ #print("pos=")
+ #print(pos)
+ time.sleep(0.01)