test_load.py 2.62 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
32
33
34
35
36
37
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


38
class TalosArmTest(RobotTestCase):
39
    RobotTestCase.ROBOT = example_robot_data.loadTalosArm()
40
41
42
    RobotTestCase.NQ = 7
    RobotTestCase.NV = 7

Guilhem Saurel's avatar
Guilhem Saurel committed
43

44
class TalosArmFloatingTest(RobotTestCase):
45
    RobotTestCase.ROBOT = example_robot_data.loadTalosArm()
46
47
48
    RobotTestCase.NQ = 14
    RobotTestCase.NV = 13

Guilhem Saurel's avatar
Guilhem Saurel committed
49

50
51
52
53
class TalosLegsTest(RobotTestCase):
    RobotTestCase.ROBOT = example_robot_data.loadTalosLegs()
    RobotTestCase.NQ = 19
    RobotTestCase.NV = 18
Guilhem Saurel's avatar
Guilhem Saurel committed
54

Guilhem Saurel's avatar
Guilhem Saurel committed
55

56
57
58
59
60
61
62
63
64
65
66
67
68
69
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)
70
71
72
73
    RobotTestCase.NQ = 19
    RobotTestCase.NV = 18


74
class TiagoTest(RobotTestCase):
75
    RobotTestCase.ROBOT = example_robot_data.loadTiago()
76
77
78
79
80
    RobotTestCase.NQ = 50
    RobotTestCase.NV = 48


class TiagoNoHandTest(RobotTestCase):
81
    RobotTestCase.ROBOT = example_robot_data.loadTiagoNoHand()
82
83
84
    RobotTestCase.NQ = 14
    RobotTestCase.NV = 12

Carlos Mastalli's avatar
Carlos Mastalli committed
85

Guilhem Saurel's avatar
Guilhem Saurel committed
86
87
88
89
90
91
class UR5Test(RobotTestCase):
    RobotTestCase.ROBOT = example_robot_data.loadUR()
    RobotTestCase.NQ = 6
    RobotTestCase.NV = 6


92
if __name__ == '__main__':
93
94
95
96
97
98
99
100
101
102
103
104
105
    test_classes_to_run = [
        HyQTest, TalosTest, TalosArmTest, TalosArmFloatingTest, TalosLegsTest, ICubTest, SoloTest, Solo12Test,
        TiagoTest, TiagoNoHandTest
    ]
    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())