bindings_joint_composite.py
Go to the documentation of this file.
1 import unittest
2 
3 import pinocchio as pin
4 
5 
6 class TestJointCompositeBindings(unittest.TestCase):
7  def test_basic(self):
8  jc = pin.JointModelComposite()
9  self.assertTrue(hasattr(jc, "joints"))
10  self.assertTrue(hasattr(jc, "njoints"))
11  self.assertTrue(hasattr(jc, "jointPlacements"))
12 
14  jc = pin.JointModelComposite()
15  self.assertTrue(jc.nq == 0)
16  self.assertTrue(len(jc.joints) == 0)
17  self.assertTrue(jc.njoints == len(jc.joints))
18 
20  jc = pin.JointModelComposite(2)
21  self.assertTrue(jc.nq == 0)
22  self.assertTrue(len(jc.joints) == 0)
23  self.assertTrue(jc.njoints == len(jc.joints))
24 
26  j1 = pin.JointModelRX()
27  self.assertTrue(j1.nq == 1)
28 
29  jc1 = pin.JointModelComposite(j1)
30  self.assertTrue(jc1.nq == 1)
31  self.assertTrue(len(jc1.joints) == 1)
32  self.assertTrue(jc1.njoints == len(jc1.joints))
33 
34  j2 = pin.JointModelRX()
35  self.assertTrue(j2.nq == 1)
36 
37  jc2 = pin.JointModelComposite(j1, pin.SE3.Random())
38  self.assertTrue(jc2.nq == 1)
39  self.assertTrue(len(jc2.joints) == 1)
40  self.assertTrue(jc2.njoints == len(jc2.joints))
41 
42  def test_add_joint(self):
43  j1 = pin.JointModelRX()
44  self.assertTrue(j1.nq == 1)
45  j2 = pin.JointModelRY()
46  self.assertTrue(j2.nq == 1)
47  j3 = pin.JointModelRZ()
48  self.assertTrue(j3.nq == 1)
49 
50  jc = pin.JointModelComposite(2)
51  self.assertTrue(jc.nq == 0)
52  self.assertTrue(len(jc.joints) == 0)
53  self.assertTrue(jc.njoints == len(jc.joints))
54 
55  jc.addJoint(j1)
56  self.assertTrue(jc.nq == 1)
57  self.assertTrue(len(jc.joints) == 1)
58  self.assertTrue(jc.njoints == len(jc.joints))
59 
60  jc.addJoint(j2)
61  self.assertTrue(jc.nq == 2)
62  self.assertTrue(len(jc.joints) == 2)
63  self.assertTrue(jc.njoints == len(jc.joints))
64 
65  jc.addJoint(j3, pin.SE3.Random())
66  self.assertTrue(jc.nq == 3)
67  self.assertTrue(jc.njoints == len(jc.joints))
68 
70  jc1 = pin.JointModelComposite()
71  jc2 = jc1.addJoint(pin.JointModelRX())
72  jc3 = jc2.addJoint(pin.JointModelRY())
73  jc4 = jc1.addJoint(pin.JointModelRZ())
74  self.assertTrue(jc1.njoints == 3)
75  self.assertTrue(jc2.njoints == 3)
76  self.assertTrue(jc3.njoints == 3)
77  self.assertTrue(jc4.njoints == 3)
78 
79  del jc1
80  del jc3
81  del jc4
82  self.assertTrue(jc2.njoints == 3)
83 
85  j1 = pin.JointModelRX()
86  self.assertTrue(j1.nq == 1)
87  j2 = pin.JointModelRY()
88  self.assertTrue(j2.nq == 1)
89  j3 = pin.JointModelRZ()
90  self.assertTrue(j3.nq == 1)
91 
92  jc = pin.JointModelComposite(j1).addJoint(j2, pin.SE3.Random()).addJoint(j3)
93 
94  self.assertTrue(jc.nq == 3)
95  self.assertTrue(len(jc.joints) == 3)
96  self.assertTrue(jc.njoints == len(jc.joints))
97 
98 
99 if __name__ == "__main__":
100  unittest.main()
bindings_joint_composite.TestJointCompositeBindings
Definition: bindings_joint_composite.py:6
bindings_joint_composite.TestJointCompositeBindings.test_add_joint
def test_add_joint(self)
Definition: bindings_joint_composite.py:42
bindings_joint_composite.TestJointCompositeBindings.test_reserve_constructor
def test_reserve_constructor(self)
Definition: bindings_joint_composite.py:19
bindings_joint_composite.TestJointCompositeBindings.test_basic
def test_basic(self)
Definition: bindings_joint_composite.py:7
bindings_joint_composite.TestJointCompositeBindings.test_add_joint_return
def test_add_joint_return(self)
Definition: bindings_joint_composite.py:69
bindings_joint_composite.TestJointCompositeBindings.test_empty_constructor
def test_empty_constructor(self)
Definition: bindings_joint_composite.py:13
bindings_joint_composite.TestJointCompositeBindings.test_add_joint_concat
def test_add_joint_concat(self)
Definition: bindings_joint_composite.py:84
bindings_joint_composite.TestJointCompositeBindings.test_joint_constructor
def test_joint_constructor(self)
Definition: bindings_joint_composite.py:25


pinocchio
Author(s):
autogenerated on Thu Dec 19 2024 03:41:25