From 466c853489c7257d4d10353b985dd20aa18c3aa9 Mon Sep 17 00:00:00 2001 From: Erwin Coumans Date: Sun, 10 Sep 2017 10:45:38 -0700 Subject: [PATCH] add testMJCF.py script, to visualize MJCF file --- .../gym/pybullet_envs/examples/testMJCF.py | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 examples/pybullet/gym/pybullet_envs/examples/testMJCF.py diff --git a/examples/pybullet/gym/pybullet_envs/examples/testMJCF.py b/examples/pybullet/gym/pybullet_envs/examples/testMJCF.py new file mode 100644 index 000000000..ebdef3b38 --- /dev/null +++ b/examples/pybullet/gym/pybullet_envs/examples/testMJCF.py @@ -0,0 +1,28 @@ +import os +import inspect +currentdir = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe()))) +parentdir = os.path.dirname(os.path.dirname(currentdir)) +os.sys.path.insert(0,parentdir) + +import pybullet as p +import pybullet_data +import time + +def test(args): + p.connect(p.GUI) + p.setAdditionalSearchPath(pybullet_data.getDataPath()) + fileName = os.path.join("mjcf", args.mjcf) + print("fileName") + print(fileName) + p.loadMJCF(fileName) + while (1): + p.stepSimulation() + p.getCameraImage(320,240) + time.sleep(0.01) + +if __name__ == '__main__': + import argparse + parser = argparse.ArgumentParser(formatter_class=argparse.ArgumentDefaultsHelpFormatter) + parser.add_argument('--mjcf', help='MJCF filename', default="humanoid.xml") + args = parser.parse_args() + test(args) \ No newline at end of file