test_load.py 3.25 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
class ANYmalKinovaTest(RobotTestCase):
    RobotTestCase.ROBOT = example_robot_data.loadANYmal(withArm="kinova")
    RobotTestCase.NQ = 27
    RobotTestCase.NV = 24


38
39
40
41
42
43
44
45
46
47
48
49
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


50
class TalosArmTest(RobotTestCase):
51
    RobotTestCase.ROBOT = example_robot_data.loadTalosArm()
52
53
54
    RobotTestCase.NQ = 7
    RobotTestCase.NV = 7

Guilhem Saurel's avatar
Guilhem Saurel committed
55

56
class TalosArmFloatingTest(RobotTestCase):
57
    RobotTestCase.ROBOT = example_robot_data.loadTalosArm()
58
59
60
    RobotTestCase.NQ = 14
    RobotTestCase.NV = 13

Guilhem Saurel's avatar
Guilhem Saurel committed
61

62
63
64
65
class TalosLegsTest(RobotTestCase):
    RobotTestCase.ROBOT = example_robot_data.loadTalosLegs()
    RobotTestCase.NQ = 19
    RobotTestCase.NV = 18
Guilhem Saurel's avatar
Guilhem Saurel committed
66

Guilhem Saurel's avatar
Guilhem Saurel committed
67

68
69
70
71
72
73
74
75
76
77
78
79
80
81
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)
82
83
84
85
    RobotTestCase.NQ = 19
    RobotTestCase.NV = 18


86
class TiagoTest(RobotTestCase):
87
    RobotTestCase.ROBOT = example_robot_data.loadTiago()
88
89
90
91
92
    RobotTestCase.NQ = 50
    RobotTestCase.NV = 48


class TiagoNoHandTest(RobotTestCase):
93
    RobotTestCase.ROBOT = example_robot_data.loadTiagoNoHand()
94
95
96
    RobotTestCase.NQ = 14
    RobotTestCase.NV = 12

Carlos Mastalli's avatar
Carlos Mastalli committed
97

Guilhem Saurel's avatar
Guilhem Saurel committed
98
99
100
101
102
103
class UR5Test(RobotTestCase):
    RobotTestCase.ROBOT = example_robot_data.loadUR()
    RobotTestCase.NQ = 6
    RobotTestCase.NV = 6


104
105
106
107
108
109
class KinovaTest(RobotTestCase):
    RobotTestCase.ROBOT = example_robot_data.loadKinova()
    RobotTestCase.NQ = 9
    RobotTestCase.NV = 6


Guilhem Saurel's avatar
Guilhem Saurel committed
110
111
112
113
114
115
class RomeoTest(RobotTestCase):
    RobotTestCase.ROBOT = example_robot_data.loadRomeo()
    RobotTestCase.NQ = 62
    RobotTestCase.NV = 61


116
if __name__ == '__main__':
117
    test_classes_to_run = [
118
        ANYmalTest, ANYmalKinovaTest, HyQTest, TalosTest, TalosArmTest, TalosArmFloatingTest, TalosLegsTest, ICubTest,
Guilhem Saurel's avatar
Guilhem Saurel committed
119
        SoloTest, Solo12Test, TiagoTest, TiagoNoHandTest, KinovaTest, RomeoTest
120
121
122
123
124
125
126
127
128
129
    ]
    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())