test_load.py 2.77 KB
Newer Older
Guilhem Saurel's avatar
Guilhem Saurel committed
1
2
#!/usr/bin/env python2

3
import sys
4
import unittest
Guilhem Saurel's avatar
Guilhem Saurel committed
5

6
import example_robot_data
Guilhem Saurel's avatar
Guilhem Saurel committed
7

8
9
10
11
12
13
14
15
16
17
18
19
20
21
22

class RobotTestCase(unittest.TestCase):
    ROBOT = None
    NQ = None
    NV = None

    def test_nq(self):
        model = self.ROBOT.model
        self.assertEqual(model.nq, self.NQ, "Wrong nq value.")

    def test_nv(self):
        model = self.ROBOT.model
        self.assertEqual(model.nv, self.NV, "Wrong nv value.")

    def test_q0(self):
Guilhem Saurel's avatar
Guilhem Saurel committed
23
24
        self.assertTrue(hasattr(self.ROBOT, "q0"), "It doesn't have q0")

25

26
27
28
29
30
31
class ANYmalTest(RobotTestCase):
    RobotTestCase.ROBOT = example_robot_data.loadANYmal()
    RobotTestCase.NQ = 19
    RobotTestCase.NV = 18


32
33
34
35
36
37
38
39
40
41
42
43
class HyQTest(RobotTestCase):
    RobotTestCase.ROBOT = example_robot_data.loadHyQ()
    RobotTestCase.NQ = 19
    RobotTestCase.NV = 18


class TalosTest(RobotTestCase):
    RobotTestCase.ROBOT = example_robot_data.loadTalos()
    RobotTestCase.NQ = 39
    RobotTestCase.NV = 38


44
class TalosArmTest(RobotTestCase):
45
    RobotTestCase.ROBOT = example_robot_data.loadTalosArm()
46
47
48
    RobotTestCase.NQ = 7
    RobotTestCase.NV = 7

Guilhem Saurel's avatar
Guilhem Saurel committed
49

50
class TalosArmFloatingTest(RobotTestCase):
51
    RobotTestCase.ROBOT = example_robot_data.loadTalosArm()
52
53
54
    RobotTestCase.NQ = 14
    RobotTestCase.NV = 13

Guilhem Saurel's avatar
Guilhem Saurel committed
55

56
57
58
59
class TalosLegsTest(RobotTestCase):
    RobotTestCase.ROBOT = example_robot_data.loadTalosLegs()
    RobotTestCase.NQ = 19
    RobotTestCase.NV = 18
Guilhem Saurel's avatar
Guilhem Saurel committed
60

Guilhem Saurel's avatar
Guilhem Saurel committed
61

62
63
64
65
66
67
68
69
70
71
72
73
74
75
class ICubTest(RobotTestCase):
    RobotTestCase.ROBOT = example_robot_data.loadICub(reduced=False)
    RobotTestCase.NQ = 39
    RobotTestCase.NV = 38


class SoloTest(RobotTestCase):
    RobotTestCase.ROBOT = example_robot_data.loadSolo()
    RobotTestCase.NQ = 15
    RobotTestCase.NV = 14


class Solo12Test(RobotTestCase):
    RobotTestCase.ROBOT = example_robot_data.loadSolo(False)
76
77
78
79
    RobotTestCase.NQ = 19
    RobotTestCase.NV = 18


80
class TiagoTest(RobotTestCase):
81
    RobotTestCase.ROBOT = example_robot_data.loadTiago()
82
83
84
85
86
    RobotTestCase.NQ = 50
    RobotTestCase.NV = 48


class TiagoNoHandTest(RobotTestCase):
87
    RobotTestCase.ROBOT = example_robot_data.loadTiagoNoHand()
88
89
90
    RobotTestCase.NQ = 14
    RobotTestCase.NV = 12

Carlos Mastalli's avatar
Carlos Mastalli committed
91

Guilhem Saurel's avatar
Guilhem Saurel committed
92
93
94
95
96
97
class UR5Test(RobotTestCase):
    RobotTestCase.ROBOT = example_robot_data.loadUR()
    RobotTestCase.NQ = 6
    RobotTestCase.NV = 6


98
if __name__ == '__main__':
99
    test_classes_to_run = [
100
101
        ANYmalTest, HyQTest, TalosTest, TalosArmTest, TalosArmFloatingTest, TalosLegsTest, ICubTest, SoloTest,
        Solo12Test, TiagoTest, TiagoNoHandTest
102
103
104
105
106
107
108
109
110
111
    ]
    loader = unittest.TestLoader()
    suites_list = []
    for test_class in test_classes_to_run:
        suite = loader.loadTestsFromTestCase(test_class)
        suites_list.append(suite)
    big_suite = unittest.TestSuite(suites_list)
    runner = unittest.TextTestRunner()
    results = runner.run(big_suite)
    sys.exit(not results.wasSuccessful())