summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorErwin Coumans <erwincoumans@google.com>2020-08-07 09:32:30 -0700
committerErwin Coumans <erwincoumans@google.com>2020-08-07 09:32:30 -0700
commita17df118f199aa3509c1bd247e188da69fe75768 (patch)
treec0a605b3ae778e2174556046c057caf3f782f191
parentf1cca2eea4c3fe511fc89dd95e6e09f00c8953c2 (diff)
downloadbullet3-a17df118f199aa3509c1bd247e188da69fe75768.tar.gz
re-add constraints.py I wanted to delete the changes, not the file!
(confusing github UI!)
-rw-r--r--examples/pybullet/examples/constraint.py28
1 files changed, 28 insertions, 0 deletions
diff --git a/examples/pybullet/examples/constraint.py b/examples/pybullet/examples/constraint.py
new file mode 100644
index 000000000..70d4a6fe9
--- /dev/null
+++ b/examples/pybullet/examples/constraint.py
@@ -0,0 +1,28 @@
+import pybullet as p
+import time
+import math
+
+import pybullet_data
+p.connect(p.GUI)
+p.setAdditionalSearchPath(pybullet_data.getDataPath())
+
+p.loadURDF("plane.urdf")
+cubeId = p.loadURDF("cube_small.urdf", 0, 0, 1)
+p.setGravity(0, 0, -10)
+p.setRealTimeSimulation(1)
+cid = p.createConstraint(cubeId, -1, -1, -1, p.JOINT_FIXED, [0, 0, 0], [0, 0, 0], [0, 0, 1])
+print(cid)
+print(p.getConstraintUniqueId(0))
+prev = [0, 0, 1]
+a = -math.pi
+while 1:
+ a = a + 0.01
+ if (a > math.pi):
+ a = -math.pi
+ time.sleep(.01)
+ p.setGravity(0, 0, -10)
+ pivot = [a, 0, 1]
+ orn = p.getQuaternionFromEuler([a, 0, 0])
+ p.changeConstraint(cid, pivot, jointChildFrameOrientation=orn, maxForce=50)
+
+p.removeConstraint(cid)