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  # with self.subTest(): # uncomment on python >= 3.4 to get full list of wrong bodies at once
31  self.assertIn(joint[12].decode(), one_kg_bodies)
32  pybullet.disconnect(client_id)
33 
34  def test_anymal(self):
35  self.check('anymal', 19, 18)
36 
37  def test_anymal_kinova(self):
38  self.check('anymal_kinova', 25, 24)
39 
41  self.check('double_pendulum', 2, 2)
42 
43  def test_hector(self):
44  self.check('hector', 7, 6)
45 
46  def test_hyq(self):
47  self.check('hyq', 19, 18)
48 
49  def test_icub(self):
50  self.check('icub', 39, 38)
51 
52  def test_icub_reduced(self):
53  self.check('icub_reduced', 36, 35)
54 
55  def test_iris(self):
56  self.check('iris', 7, 6)
57 
58  def test_kinova(self):
59  self.check('kinova', 9, 6)
60 
61  def test_panda(self):
62  self.check('panda', 9, 9)
63 
64  def test_romeo(self):
65  self.check('romeo', 62, 61)
66 
68  self.check('simple_humanoid', 36, 35, one_kg_bodies=['LARM_LINK3', 'RARM_LINK3'])
69 
71  self.check('simple_humanoid_classical', 36, 35, one_kg_bodies=['LARM_LINK3', 'RARM_LINK3'])
72 
73  def test_solo(self):
74  self.check('solo', 15, 14)
75 
76  def test_solo12(self):
77  self.check('solo12', 19, 18)
78 
79  def test_talos(self):
80  self.check('talos', 39, 38)
81 
82  def test_talos_box(self):
83  self.check('talos_box', 39, 38)
84 
85  def test_talos_full(self):
86  self.check('talos_full', 51, 50)
87 
89  self.check('talos_full_box', 51, 50)
90 
91  def test_talos_arm(self):
92  self.check('talos_arm', 7, 7)
93 
94  def test_talos_legs(self):
95  self.check('talos_legs', 19, 18)
96 
97  def test_tiago(self):
98  self.check('tiago', 50, 48)
99 
101  self.check('tiago_no_hand', 14, 12)
102 
103  def test_ur5(self):
104  self.check('ur5', 6, 6)
105 
106  def test_ur5_gripper(self):
107  self.check('ur5_gripper', 6, 6)
108 
109  def test_ur5_limited(self):
110  self.check('ur5_limited', 6, 6)
111 
112 
113 if __name__ == '__main__':
114  unittest.main()
def test_talos_full_box(self)
Definition: test_load.py:88
def test_ur5_gripper(self)
Definition: test_load.py:106
def test_talos_arm(self)
Definition: test_load.py:91
def check_pybullet(self, urdf, one_kg_bodies)
Definition: test_load.py:23
def test_icub_reduced(self)
Definition: test_load.py:52
def test_talos_full(self)
Definition: test_load.py:85
def test_talos_legs(self)
Definition: test_load.py:94
def test_anymal_kinova(self)
Definition: test_load.py:37
def load_full(name, display=False, rootNodeName='')
def test_tiago_no_hand(self)
Definition: test_load.py:100
def test_simple_humanoid_classical(self)
Definition: test_load.py:70
def test_talos_box(self)
Definition: test_load.py:82
def test_double_pendulum(self)
Definition: test_load.py:40
def test_simple_humanoid(self)
Definition: test_load.py:67
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:109


pinocchio
Author(s):
autogenerated on Tue Jun 1 2021 02:45:04