From 506fb4d04641ff02f242df17245ef8a01e001cf4 Mon Sep 17 00:00:00 2001
From: Guilhem Saurel <guilhem.saurel@laas.fr>
Date: Wed, 29 Jul 2020 19:48:19 +0200
Subject: [PATCH] [Tests] use load

Which lead to find that __main__ was missing the variations of icub &
ur5
---
 python/example_robot_data/robots_loader.py | 13 ++++++-
 unittest/test_load.py                      | 42 ++++++++++++----------
 2 files changed, 35 insertions(+), 20 deletions(-)

diff --git a/python/example_robot_data/robots_loader.py b/python/example_robot_data/robots_loader.py
index 59294e2..1df545a 100644
--- a/python/example_robot_data/robots_loader.py
+++ b/python/example_robot_data/robots_loader.py
@@ -237,7 +237,12 @@ ROBOTS = {
     'double_pendulum': (loadDoublePendulum, {}),
     'hector': (loadHector, {}),
     'hyq': (loadHyQ, {}),
-    'icub': (loadICub, {}),
+    'icub': (loadICub, {
+        'reduced': False
+    }),
+    'icub_reduced': (loadICub, {
+        'reduced': True
+    }),
     'iris': (loadIris, {}),
     'kinova': (loadKinova, {}),
     'panda': (loadPanda, {}),
@@ -258,6 +263,12 @@ ROBOTS = {
         'hand': False
     }),
     'ur5': (loadUR, {}),
+    'ur5_gripper': (loadUR, {
+        'gripper': True
+    }),
+    'ur5_limited': (loadUR, {
+        'limited': True
+    }),
 }
 
 
diff --git a/unittest/test_load.py b/unittest/test_load.py
index 0fa6b95..70abac2 100755
--- a/unittest/test_load.py
+++ b/unittest/test_load.py
@@ -2,66 +2,70 @@
 
 import unittest
 
-import example_robot_data as erd
+from example_robot_data import load
 
 
 class RobotTestCase(unittest.TestCase):
-    def check(self, robot, expected_nq, expected_nv):
+    def check(self, name, expected_nq, expected_nv):
         """Helper function for the real tests"""
+        robot = load(name, display=False)
         self.assertEqual(robot.model.nq, expected_nq)
         self.assertEqual(robot.model.nv, expected_nv)
         self.assertTrue(hasattr(robot, "q0"))
 
     def test_anymal(self):
-        self.check(erd.loadANYmal(), 19, 18)
+        self.check('anymal', 19, 18)
 
     def test_anymal_kinova(self):
-        self.check(erd.loadANYmal(withArm="kinova"), 25, 24)
+        self.check('anymal_kinova', 25, 24)
 
     def test_hyq(self):
-        self.check(erd.loadHyQ(), 19, 18)
+        self.check('hyq', 19, 18)
 
     def test_talos(self):
-        self.check(erd.loadTalos(), 39, 38)
+        self.check('talos', 39, 38)
 
     def test_talos_arm(self):
-        self.check(erd.loadTalos(arm=True), 7, 7)
+        self.check('talos_arm', 7, 7)
 
     def test_talos_legs(self):
-        self.check(erd.loadTalos(legs=True), 19, 18)
+        self.check('talos_legs', 19, 18)
 
     def test_icub(self):
-        self.check(erd.loadICub(reduced=False), 39, 38)
+        self.check('icub', 39, 38)
+
+    def test_icub_reduced(self):
+        self.check('icub_reduced', 36, 35)
 
     def test_solo(self):
-        self.check(erd.loadSolo(), 15, 14)
+        self.check('solo', 15, 14)
 
     def test_solo12(self):
-        self.check(erd.loadSolo(False), 19, 18)
+        self.check('solo12', 19, 18)
 
     def test_tiago(self):
-        self.check(erd.loadTiago(), 50, 48)
+        self.check('tiago', 50, 48)
 
     def test_tiago_no_hand(self):
-        self.check(erd.loadTiago(hand=False), 14, 12)
+        self.check('tiago_no_hand', 14, 12)
 
     def test_ur5(self):
-        self.check(erd.loadUR(), 6, 6)
+        self.check('ur5', 6, 6)
 
     def test_ur5_limited(self):
-        self.check(erd.loadUR(limited=True), 6, 6)
+        self.check('ur5_limited', 6, 6)
 
     def test_ur5_gripper(self):
-        self.check(erd.loadUR(gripper=True), 6, 6)
+        self.check('ur5_gripper', 6, 6)
 
     def test_kinova(self):
-        self.check(erd.loadKinova(), 9, 6)
+        self.check('kinova', 9, 6)
 
     def test_romeo(self):
-        self.check(erd.loadRomeo(), 62, 61)
+        self.check('romeo', 62, 61)
 
     def test_panda(self):
-        self.check(erd.loadPanda(), 9, 9)
+        self.check('panda', 9, 9)
 
 
 if __name__ == '__main__':
-- 
GitLab