From 793807978b4225254114261abbdf4ef24360d00e Mon Sep 17 00:00:00 2001
From: Valenza Florian <fvalenza@laas.fr>
Date: Fri, 29 Apr 2016 15:20:48 +0200
Subject: [PATCH] [Python][Unittest] Fixed absolute path to model

---
 python/bindings_SE3.py             |  3 ---
 python/bindings_force.py           |  2 --
 python/bindings_frame.py           | 10 ++++++----
 python/bindings_geometry_object.py | 12 +++++++++---
 python/bindings_inertia.py         |  2 --
 python/bindings_motion.py          |  3 ---
 python/tests.py                    |  4 ++--
 7 files changed, 17 insertions(+), 19 deletions(-)

diff --git a/python/bindings_SE3.py b/python/bindings_SE3.py
index d8430ecfc..f749cb6f8 100644
--- a/python/bindings_SE3.py
+++ b/python/bindings_SE3.py
@@ -91,6 +91,3 @@ class TestSE3Bindings(unittest.TestCase):
         aXc = aXb * bXc
         self.assertTrue(np.allclose(amc.action,aXc))
 
-
-if __name__ == '__main__':
-    unittest.main()
diff --git a/python/bindings_force.py b/python/bindings_force.py
index 6e8a75c81..50fb321c1 100644
--- a/python/bindings_force.py
+++ b/python/bindings_force.py
@@ -70,5 +70,3 @@ class TestForceBindings(unittest.TestCase):
 
 
 
-if __name__ == '__main__':
-    unittest.main()
diff --git a/python/bindings_frame.py b/python/bindings_frame.py
index 8367945e6..88b458fda 100644
--- a/python/bindings_frame.py
+++ b/python/bindings_frame.py
@@ -3,6 +3,7 @@ import pinocchio as se3
 import numpy as np
 from pinocchio.utils import eye,zero,rand
 from pinocchio.robot_wrapper import RobotWrapper
+import os
 
 ones = lambda n: np.matrix(np.ones([n, 1] if isinstance(n, int) else n), np.double)
 
@@ -16,8 +17,11 @@ class TestFrameBindings(unittest.TestCase):
     m3ones = eye(3)
     m4ones = eye(4)
 
-    hint_list = ["/local/fvalenza/devel/src/pinocchio/models", "wrong/hint"] # hint list
-    robot = RobotWrapper("/local/fvalenza/devel/src/pinocchio/models/romeo.urdf", hint_list, se3.JointModelFreeFlyer())
+    current_file = os.path.dirname(os.path.abspath(__file__))
+    pinocchio_models_dir = os.path.abspath(os.path.join(current_file, '../models'))
+    romeo_model_path = os.path.abspath(os.path.join(current_file, '../models/romeo.urdf'))
+    hint_list = [pinocchio_models_dir, "wrong/hint"]  # hint list
+    robot = RobotWrapper(romeo_model_path, hint_list, se3.JointModelFreeFlyer())
 
     def test_name_get_set(self):
         f = self.robot.model.operational_frames[1]
@@ -40,5 +44,3 @@ class TestFrameBindings(unittest.TestCase):
         self.assertTrue(np.allclose(f.placement.homogeneous , new_m.homogeneous))
 
 
-if __name__ == '__main__':
-    unittest.main()
diff --git a/python/bindings_geometry_object.py b/python/bindings_geometry_object.py
index 9bbf74eca..1aa890b47 100644
--- a/python/bindings_geometry_object.py
+++ b/python/bindings_geometry_object.py
@@ -3,6 +3,7 @@ import pinocchio as se3
 import numpy as np
 from pinocchio.utils import eye,zero,rand
 from pinocchio.robot_wrapper import RobotWrapper
+import os
 
 ones = lambda n: np.matrix(np.ones([n, 1] if isinstance(n, int) else n), np.double)
 
@@ -16,8 +17,12 @@ class TestGeometryObjectBindings(unittest.TestCase):
     m3ones = eye(3)
     m4ones = eye(4)
 
-    hint_list = ["/local/fvalenza/devel/src/pinocchio/models", "wrong/hint"] # hint list
-    robot = RobotWrapper("/local/fvalenza/devel/src/pinocchio/models/romeo.urdf", hint_list, se3.JointModelFreeFlyer())
+
+    current_file =  os.path.dirname(os.path.abspath(__file__))
+    pinocchio_models_dir = os.path.abspath(os.path.join(current_file, '../models'))
+    romeo_model_path = os.path.abspath(os.path.join(current_file, '../models/romeo.urdf'))
+    hint_list = [pinocchio_models_dir, "wrong/hint"] # hint list
+    robot = RobotWrapper(romeo_model_path, hint_list, se3.JointModelFreeFlyer())
 
     def test_name_get_set(self):
         col = self.robot.geometry_model.collision_objects[1]
@@ -40,8 +45,9 @@ class TestGeometryObjectBindings(unittest.TestCase):
         self.assertTrue(np.allclose(col.placement.homogeneous , new_m.homogeneous))
 
     def test_meshpath_get(self):
+        expected_mesh_path = os.path.join(self.pinocchio_models_dir,'meshes/romeo/collision/LHipPitch.dae')
         col = self.robot.geometry_model.collision_objects[1]
-        self.assertTrue(col.mesh_path == '/local/fvalenza/devel/src/pinocchio/models/meshes/romeo/collision/LHipPitch.dae')
+        self.assertTrue(col.mesh_path == expected_mesh_path)
 
 if __name__ == '__main__':
     unittest.main()
diff --git a/python/bindings_inertia.py b/python/bindings_inertia.py
index 9c0062235..a8bf97ed9 100644
--- a/python/bindings_inertia.py
+++ b/python/bindings_inertia.py
@@ -85,5 +85,3 @@ class TestInertiaBindings(unittest.TestCase):
 
 
 
-if __name__ == '__main__':
-    unittest.main()
diff --git a/python/bindings_motion.py b/python/bindings_motion.py
index 794fd5e41..b9b02ea89 100644
--- a/python/bindings_motion.py
+++ b/python/bindings_motion.py
@@ -67,6 +67,3 @@ class TestMotionBindings(unittest.TestCase):
         self.assertTrue(np.allclose((v ** v).vector, zero(6)))
 
 
-
-if __name__ == '__main__':
-    unittest.main()
diff --git a/python/tests.py b/python/tests.py
index 156c8f2aa..cdd07c38b 100755
--- a/python/tests.py
+++ b/python/tests.py
@@ -7,8 +7,8 @@ from bindings_SE3 import TestSE3Bindings
 from bindings_force import TestForceBindings
 from bindings_motion import TestMotionBindings
 from bindings_inertia import TestInertiaBindings
-from bindings_frame import TestFrameBindings
-from bindings_geometry_object import TestGeometryObjectBindings
+# from bindings_frame import TestFrameBindings # No geometry module yet on travis
+# from bindings_geometry_object import TestGeometryObjectBindings  # Python Class RobotWrapper needs geometry module to not raise Exception
 from explog import TestExpLog  # noqa
 from model import TestModel  # noqa
 from rpy import TestRPY  # noqa
-- 
GitLab