From 23f235e44929ccdfa8284c0f63cdfa10e20eac2b Mon Sep 17 00:00:00 2001 From: erwincoumans Date: Sun, 1 Jul 2018 14:49:34 -0700 Subject: [PATCH] PyBullet: add example to enable another physics engine backend (DART, MuJoCo) --- .../pybullet/examples/otherPhysicsEngine.py | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 examples/pybullet/examples/otherPhysicsEngine.py diff --git a/examples/pybullet/examples/otherPhysicsEngine.py b/examples/pybullet/examples/otherPhysicsEngine.py new file mode 100644 index 000000000..2786b1c66 --- /dev/null +++ b/examples/pybullet/examples/otherPhysicsEngine.py @@ -0,0 +1,32 @@ +import pybullet as p +import time + +#p.connect(p.DIRECT) +#p.connect(p.DART) +p.connect(p.MuJoCo) + +#p.connect(p.GUI) +bodies = p.loadMJCF("mjcf/capsule.xml") +print("bodies=",bodies) + +numBodies = p.getNumBodies() +print("numBodies=",numBodies) +for i in range (numBodies): + print("bodyInfo[",i,"]=",p.getBodyInfo(i)) + +p.setGravity(0,0,-10) +timeStep = 1./240. +p.setPhysicsEngineParameter(fixedTimeStep=timeStep) + +#while (p.isConnected()): +for i in range (1000): + p.stepSimulation() + + for b in bodies: + pos,orn=p.getBasePositionAndOrientation(b) + print("pos[",b,"]=",pos) + print("orn[",b,"]=",orn) + linvel,angvel=p.getBaseVelocity(b) + print("linvel[",b,"]=",linvel) + print("angvel[",b,"]=",angvel) + time.sleep(timeStep)