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


pinocchio
Author(s):
autogenerated on Fri Jun 23 2023 02:38:33