From ec0a182a124731d3968e13419db4e3110b7954b6 Mon Sep 17 00:00:00 2001 From: Erwin Coumans Date: Tue, 28 Nov 2017 21:53:26 -0800 Subject: [PATCH 1/6] add pybullet unittests.py with travis support --- .travis.yml | 3 ++ examples/pybullet/unittests/unittests.py | 46 ++++++++++++++++++++++++ setup.py | 2 +- 3 files changed, 50 insertions(+), 1 deletion(-) create mode 100644 examples/pybullet/unittests/unittests.py diff --git a/.travis.yml b/.travis.yml index d2ad176f4..20e5c857a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,6 +10,7 @@ addons: packages: - python3 + script: - echo "CXX="$CXX - echo "CC="$CC @@ -25,3 +26,5 @@ script: - make -j8 - ctest -j8 --output-on-failure - sudo make install + - sudo python3 setup.py install + - python3 examples/pybullet/unittests/unittests.py diff --git a/examples/pybullet/unittests/unittests.py b/examples/pybullet/unittests/unittests.py new file mode 100644 index 000000000..3975c44af --- /dev/null +++ b/examples/pybullet/unittests/unittests.py @@ -0,0 +1,46 @@ +import unittest +import pybullet +import time + +class TestPybulletMethods(unittest.TestCase): + + def test_import(self): + import pybullet as p + self.assertGreater(p.getAPIVersion(), 201700000) + + def test_connect_direct(self): + import pybullet as p + cid = p.connect(p.DIRECT) + self.assertEqual(cid,0) + p.disconnect() + + def test_loadurdf(self): + import pybullet as p + p.connect(p.DIRECT) + ob = p.loadURDF("r2d2.urdf") + self.assertEqual(ob,0) + p.disconnect() + + def test_rolling_friction(self): + import pybullet as p + p.connect(p.DIRECT) + p.loadURDF("plane.urdf") + sphere = p.loadURDF("sphere2.urdf",[0,0,1]) + p.resetBaseVelocity(sphere,linearVelocity=[1,0,0]) + p.changeDynamics(sphere,-1,linearDamping=0,angularDamping=0) + #p.changeDynamics(sphere,-1,rollingFriction=0) + p.setGravity(0,0,-10) + for i in range (1000): + p.stepSimulation() + vel = p.getBaseVelocity(sphere) + self.assertLess(vel[0][0],1e-10) + self.assertLess(vel[0][1],1e-10) + self.assertLess(vel[0][2],1e-10) + self.assertLess(vel[1][0],1e-10) + self.assertLess(vel[1][1],1e-10) + self.assertLess(vel[1][2],1e-10) + p.disconnect() + +if __name__ == '__main__': + unittest.main() + diff --git a/setup.py b/setup.py index f8faa2d37..e86b79fc3 100644 --- a/setup.py +++ b/setup.py @@ -442,7 +442,7 @@ print("-----") setup( name = 'pybullet', - version='1.7.3', + version='1.7.4', description='Official Python Interface for the Bullet Physics SDK specialized for Robotics Simulation and Reinforcement Learning', long_description='pybullet is an easy to use Python module for physics simulation, robotics and deep reinforcement learning based on the Bullet Physics SDK. With pybullet you can load articulated bodies from URDF, SDF and other file formats. pybullet provides forward dynamics simulation, inverse dynamics computation, forward and inverse kinematics and collision detection and ray intersection queries. Aside from physics simulation, pybullet supports to rendering, with a CPU renderer and OpenGL visualization and support for virtual reality headsets.', url='https://github.com/bulletphysics/bullet3', From eb9c252147d5037b3b00bb5311d5748805d5cb88 Mon Sep 17 00:00:00 2001 From: Erwin Coumans Date: Tue, 28 Nov 2017 22:17:24 -0800 Subject: [PATCH 2/6] update travis to add setuptools --- .travis.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 20e5c857a..18817a077 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,6 +14,10 @@ addons: script: - echo "CXX="$CXX - echo "CC="$CC + - pip install -U pip wheel + - pip install setuptools + - sudo python3 setup.py install + - python3 examples/pybullet/unittests/unittests.py - cmake . -DBUILD_PYBULLET=ON -G"Unix Makefiles" #-DCMAKE_CXX_FLAGS=-Werror - make -j8 - ctest -j8 --output-on-failure @@ -26,5 +30,3 @@ script: - make -j8 - ctest -j8 --output-on-failure - sudo make install - - sudo python3 setup.py install - - python3 examples/pybullet/unittests/unittests.py From 629e8d06d1addb052c401db3601e2e274915bfed Mon Sep 17 00:00:00 2001 From: Erwin Coumans Date: Tue, 28 Nov 2017 22:19:26 -0800 Subject: [PATCH 3/6] more travis fun --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 18817a077..1e4c3e1d8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,8 +14,8 @@ addons: script: - echo "CXX="$CXX - echo "CC="$CC - - pip install -U pip wheel - - pip install setuptools + - sudo pip3 install -U pip wheel + - sudo pip3 install setuptools - sudo python3 setup.py install - python3 examples/pybullet/unittests/unittests.py - cmake . -DBUILD_PYBULLET=ON -G"Unix Makefiles" #-DCMAKE_CXX_FLAGS=-Werror From 2c60362e6c3f61c935c84f15916e0933797aca7e Mon Sep 17 00:00:00 2001 From: Erwin Coumans Date: Tue, 28 Nov 2017 22:22:59 -0800 Subject: [PATCH 4/6] travis fun2 --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 1e4c3e1d8..95298291c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,6 +14,7 @@ addons: script: - echo "CXX="$CXX - echo "CC="$CC + - sudo apt-get install python3-pip - sudo pip3 install -U pip wheel - sudo pip3 install setuptools - sudo python3 setup.py install From 5736018b663229fa47cc5aaebf8d1ab8a964343c Mon Sep 17 00:00:00 2001 From: Erwin Coumans Date: Tue, 28 Nov 2017 22:29:11 -0800 Subject: [PATCH 5/6] travis: verbose pybullet unittests.py --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 95298291c..c9263b636 100644 --- a/.travis.yml +++ b/.travis.yml @@ -18,7 +18,7 @@ script: - sudo pip3 install -U pip wheel - sudo pip3 install setuptools - sudo python3 setup.py install - - python3 examples/pybullet/unittests/unittests.py + - python3 examples/pybullet/unittests/unittests.py --verbose - cmake . -DBUILD_PYBULLET=ON -G"Unix Makefiles" #-DCMAKE_CXX_FLAGS=-Werror - make -j8 - ctest -j8 --output-on-failure From defda0135cc252da21f1310fa659fdf562258774 Mon Sep 17 00:00:00 2001 From: Erwin Coumans Date: Tue, 28 Nov 2017 23:11:31 -0800 Subject: [PATCH 6/6] fix clang part --- .travis.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index c9263b636..b3c3f108b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,11 +14,11 @@ addons: script: - echo "CXX="$CXX - echo "CC="$CC - - sudo apt-get install python3-pip - - sudo pip3 install -U pip wheel - - sudo pip3 install setuptools - - sudo python3 setup.py install - - python3 examples/pybullet/unittests/unittests.py --verbose + - if [ "$CXX" = "g++" ]; then sudo apt-get install python3-pip; fi + - if [ "$CXX" = "g++" ]; then sudo pip3 install -U pip wheel; fi + - if [ "$CXX" = "g++" ]; then sudo pip3 install setuptools; fi + - if [ "$CXX" = "g++" ]; then sudo python3 setup.py install; fi + - if [ "$CXX" = "g++" ]; then python3 examples/pybullet/unittests/unittests.py --verbose; fi - cmake . -DBUILD_PYBULLET=ON -G"Unix Makefiles" #-DCMAKE_CXX_FLAGS=-Werror - make -j8 - ctest -j8 --output-on-failure