test_load.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 
3 import unittest
4 
5 try:
6  import pybullet
7 except ImportError:
8  pybullet = False
9 
10 from example_robot_data import load_full
11 
12 
13 class RobotTestCase(unittest.TestCase):
14  def check(self, name, expected_nq, expected_nv, one_kg_bodies=[]):
15  """Helper function for the real tests"""
16  robot, _, urdf, _ = load_full(name, display=False, verbose=True)
17  self.assertEqual(robot.model.nq, expected_nq)
18  self.assertEqual(robot.model.nv, expected_nv)
19  self.assertTrue(hasattr(robot, "q0"))
20  self.assertTrue(hasattr(robot, "urdf"))
21  if pybullet:
22  self.check_pybullet(urdf, one_kg_bodies)
23 
24  def check_pybullet(self, urdf, one_kg_bodies):
25  client_id = pybullet.connect(pybullet.DIRECT)
26  robot_id = pybullet.loadURDF(urdf, physicsClientId=client_id)
27  for joint_id in range(pybullet.getNumJoints(robot_id, client_id)):
28  dynamics = pybullet.getDynamicsInfo(robot_id, joint_id, client_id)
29  if dynamics[0] == 1:
30  joint = pybullet.getJointInfo(robot_id, joint_id, client_id)
31  # uncomment on python >= 3.4 to get full list of wrong bodies at once
32  # with self.subTest():
33  self.assertIn(joint[12].decode(), one_kg_bodies)
34  pybullet.disconnect(client_id)
35 
36  def test_b1(self):
37  self.check("b1", 19, 18)
38 
39  def test_go1(self):
40  self.check("go1", 19, 18)
41 
42  def test_a1(self):
43  self.check("a1", 19, 18)
44 
45  def test_anymal(self):
46  self.check("anymal", 19, 18)
47 
48  def test_anymal_c(self):
49  self.check("anymal_c", 19, 18)
50 
51  def test_anymal_kinova(self):
52  self.check("anymal_kinova", 25, 24)
53 
54  def test_baxter(self):
55  self.check("baxter", 19, 19)
56 
57  def test_cassie(self):
58  try:
59  self.check("cassie", 29, 28)
60  except ImportError:
61  import pinocchio
62 
63  pin_version = tuple(int(i) for i in pinocchio.__version__.split("."))
64  self.assertLess(pin_version, (2, 9, 1))
65 
67  self.check("double_pendulum", 2, 2)
68 
70  self.check("double_pendulum_continuous", 4, 2)
71 
73  self.check("double_pendulum_simple", 2, 2)
74 
75  def test_asr(self):
76  self.check("asr_twodof", 2, 2, one_kg_bodies=["ground"])
77 
78  def test_hector(self):
79  self.check("hector", 7, 6)
80 
81  def test_hyq(self):
82  self.check("hyq", 19, 18)
83 
84  def test_icub(self):
85  self.check("icub", 39, 38)
86 
87  def test_icub_reduced(self):
88  self.check("icub_reduced", 36, 35)
89 
90  def test_iris(self):
91  self.check("iris", 7, 6)
92 
93  def test_kinova(self):
94  self.check("kinova", 9, 6)
95 
96  def test_panda(self):
97  self.check("panda", 9, 9)
98 
99  def test_allegro_right(self):
100  self.check("allegro_right_hand", 16, 16)
101 
102  def test_allegro_left(self):
103  self.check("allegro_left_hand", 16, 16)
104 
105  def test_quadruped(self):
106  self.check("quadruped", 15, 14)
107 
108  def test_romeo(self):
109  self.check("romeo", 62, 61)
110 
112  self.check(
113  "simple_humanoid", 36, 35, one_kg_bodies=["LARM_LINK3", "RARM_LINK3"]
114  )
115 
117  self.check(
118  "simple_humanoid_classical",
119  36,
120  35,
121  one_kg_bodies=["LARM_LINK3", "RARM_LINK3"],
122  )
123 
124  def test_bolt(self):
125  self.check("bolt", 13, 12)
126 
127  def test_solo8(self):
128  self.check("solo8", 15, 14)
129 
130  def test_solo12(self):
131  self.check("solo12", 19, 18)
132 
133  def test_finger_edu(self):
134  self.check("finger_edu", 3, 3, one_kg_bodies=["finger_base_link"])
135 
136  def test_talos(self):
137  self.check("talos", 39, 38)
138 
139  def test_laikago(self):
140  self.check("laikago", 19, 18)
141 
142  def test_talos_box(self):
143  self.check("talos_box", 39, 38)
144 
145  def test_talos_full(self):
146  self.check("talos_full", 51, 50)
147 
149  self.check("talos_full_box", 51, 50)
150 
151  def test_talos_arm(self):
152  self.check("talos_arm", 7, 7)
153 
154  def test_talos_legs(self):
155  self.check("talos_legs", 19, 18)
156 
157  def test_tiago(self):
158  self.check("tiago", 50, 48)
159 
160  def test_tiago_dual(self):
161  self.check("tiago_dual", 111, 101)
162 
164  self.check("tiago_no_hand", 14, 12)
165 
166  def test_ur3(self):
167  self.check("ur3", 6, 6)
168 
169  def test_ur3_gripper(self):
170  self.check("ur3_gripper", 6, 6)
171 
172  def test_ur3_limited(self):
173  self.check("ur3_limited", 6, 6)
174 
175  def test_ur5(self):
176  self.check("ur5", 6, 6)
177 
178  def test_ur5_gripper(self):
179  self.check("ur5_gripper", 6, 6)
180 
181  def test_ur5_limited(self):
182  self.check("ur5_limited", 6, 6)
183 
184  def test_ur10(self):
185  self.check("ur10", 6, 6)
186 
187  def test_ur10_limited(self):
188  self.check("ur10_limited", 6, 6)
189 
190 
191 if __name__ == "__main__":
192  unittest.main()
test_load.RobotTestCase.test_double_pendulum_continuous
def test_double_pendulum_continuous(self)
Definition: test_load.py:69
test_load.RobotTestCase.test_asr
def test_asr(self)
Definition: test_load.py:75
test_load.RobotTestCase
Definition: test_load.py:13
test_load.RobotTestCase.test_allegro_left
def test_allegro_left(self)
Definition: test_load.py:102
test_load.RobotTestCase.test_anymal
def test_anymal(self)
Definition: test_load.py:45
test_load.RobotTestCase.test_romeo
def test_romeo(self)
Definition: test_load.py:108
test_load.RobotTestCase.test_simple_humanoid_classical
def test_simple_humanoid_classical(self)
Definition: test_load.py:116
test_load.RobotTestCase.test_go1
def test_go1(self)
Definition: test_load.py:39
test_load.RobotTestCase.test_ur3
def test_ur3(self)
Definition: test_load.py:166
test_load.RobotTestCase.test_kinova
def test_kinova(self)
Definition: test_load.py:93
example_robot_data.robots_loader.load_full
def load_full(name, display=False, rootNodeName="", verbose=False)
Definition: robots_loader.py:639
test_load.RobotTestCase.test_simple_humanoid
def test_simple_humanoid(self)
Definition: test_load.py:111
test_load.RobotTestCase.check_pybullet
def check_pybullet(self, urdf, one_kg_bodies)
Definition: test_load.py:24
test_load.RobotTestCase.test_finger_edu
def test_finger_edu(self)
Definition: test_load.py:133
test_load.RobotTestCase.test_solo12
def test_solo12(self)
Definition: test_load.py:130
test_load.RobotTestCase.test_panda
def test_panda(self)
Definition: test_load.py:96
test_load.RobotTestCase.test_icub
def test_icub(self)
Definition: test_load.py:84
test_load.RobotTestCase.test_solo8
def test_solo8(self)
Definition: test_load.py:127
test_load.RobotTestCase.test_anymal_c
def test_anymal_c(self)
Definition: test_load.py:48
test_load.RobotTestCase.test_ur5_limited
def test_ur5_limited(self)
Definition: test_load.py:181
test_load.RobotTestCase.test_bolt
def test_bolt(self)
Definition: test_load.py:124
test_load.RobotTestCase.test_talos
def test_talos(self)
Definition: test_load.py:136
test_load.RobotTestCase.test_talos_full
def test_talos_full(self)
Definition: test_load.py:145
test_load.RobotTestCase.test_tiago
def test_tiago(self)
Definition: test_load.py:157
test_load.RobotTestCase.check
def check(self, name, expected_nq, expected_nv, one_kg_bodies=[])
Definition: test_load.py:14
test_load.RobotTestCase.test_laikago
def test_laikago(self)
Definition: test_load.py:139
test_load.RobotTestCase.test_baxter
def test_baxter(self)
Definition: test_load.py:54
test_load.RobotTestCase.test_ur10
def test_ur10(self)
Definition: test_load.py:184
test_load.RobotTestCase.test_talos_arm
def test_talos_arm(self)
Definition: test_load.py:151
test_load.RobotTestCase.test_double_pendulum_simple
def test_double_pendulum_simple(self)
Definition: test_load.py:72
test_load.RobotTestCase.test_talos_legs
def test_talos_legs(self)
Definition: test_load.py:154
test_load.RobotTestCase.test_a1
def test_a1(self)
Definition: test_load.py:42
test_load.RobotTestCase.test_anymal_kinova
def test_anymal_kinova(self)
Definition: test_load.py:51
test_load.RobotTestCase.test_allegro_right
def test_allegro_right(self)
Definition: test_load.py:99
test_load.RobotTestCase.test_tiago_dual
def test_tiago_dual(self)
Definition: test_load.py:160
test_load.RobotTestCase.test_iris
def test_iris(self)
Definition: test_load.py:90
test_load.RobotTestCase.test_b1
def test_b1(self)
Definition: test_load.py:36
test_load.RobotTestCase.test_ur5_gripper
def test_ur5_gripper(self)
Definition: test_load.py:178
test_load.RobotTestCase.test_ur5
def test_ur5(self)
Definition: test_load.py:175
test_load.RobotTestCase.test_hyq
def test_hyq(self)
Definition: test_load.py:81
test_load.RobotTestCase.test_talos_full_box
def test_talos_full_box(self)
Definition: test_load.py:148
test_load.RobotTestCase.test_ur3_limited
def test_ur3_limited(self)
Definition: test_load.py:172
test_load.RobotTestCase.test_tiago_no_hand
def test_tiago_no_hand(self)
Definition: test_load.py:163
test_load.RobotTestCase.test_quadruped
def test_quadruped(self)
Definition: test_load.py:105
test_load.RobotTestCase.test_ur3_gripper
def test_ur3_gripper(self)
Definition: test_load.py:169
test_load.RobotTestCase.test_double_pendulum
def test_double_pendulum(self)
Definition: test_load.py:66
test_load.RobotTestCase.test_hector
def test_hector(self)
Definition: test_load.py:78
test_load.RobotTestCase.test_ur10_limited
def test_ur10_limited(self)
Definition: test_load.py:187
test_load.RobotTestCase.test_icub_reduced
def test_icub_reduced(self)
Definition: test_load.py:87
test_load.RobotTestCase.test_cassie
def test_cassie(self)
Definition: test_load.py:57
test_load.RobotTestCase.test_talos_box
def test_talos_box(self)
Definition: test_load.py:142


pinocchio
Author(s):
autogenerated on Sun Dec 22 2024 03:41:12