2 import pinocchio
as pin
5 from test_case
import PinocchioTestCase
as TestCase
10 self.
model = pin.buildSampleModelHumanoidRandom()
14 self.assertEqual(model.nbodies, 1)
15 self.assertEqual(model.nq, 0)
16 self.assertEqual(model.nv, 0)
17 model.name =
"empty_model" 22 idx = model.addJoint(idx, pin.JointModelRY(), pin.SE3.Identity(),
'joint_'+str(idx+1))
29 me = np.array([MAX_EFF])
30 mv = np.array([MAX_VEL])
31 lb = np.array([MIN_POS])
32 ub = np.array([MAX_POS])
33 idx = model.addJoint(idx, pin.JointModelRY(), pin.SE3.Identity(),
'joint_'+str(idx+1),me,mv,lb,ub)
35 self.assertEqual(model.nbodies, 1)
36 self.assertEqual(model.njoints, 3)
37 self.assertEqual(model.nq, 2)
38 self.assertEqual(model.nv, 2)
40 self.assertEqual(float(model.effortLimit[1]), MAX_EFF)
41 self.assertEqual(float(model.velocityLimit[1]), MAX_VEL)
42 self.assertEqual(float(model.lowerPositionLimit[1]), MIN_POS)
43 self.assertEqual(float(model.upperPositionLimit[1]), MAX_POS)
48 self.assertEqual(model.nbodies, nb)
49 self.assertEqual(model.nq, nb - 1 + 6)
50 self.assertEqual(model.nv, nb - 1 + 5)
54 model.inertias[1] = model.inertias[2]
55 self.assertApprox(model.inertias[1].np, model.inertias[2].np)
59 model.jointPlacements[1] = model.jointPlacements[2]
60 self.assertApprox(model.jointPlacements[1].np, model.jointPlacements[2].np)
61 self.assertEqual(model.parents[0], 0)
62 self.assertEqual(model.parents[1], 0)
63 model.parents[2] = model.parents[1]
64 self.assertEqual(model.parents[2], model.parents[1])
65 self.assertEqual(model.names[0],
"universe")
68 self.assertApprox(self.model.gravity.np, np.array([0, 0, -9.81, 0, 0, 0]).T)
72 data = model.createData()
76 qddot =
zero(model.nv)
77 for i
in range(model.nbodies):
78 data.a[i] = pin.Motion.Zero()
80 pin.rnea(model, data, q, qdot, qddot)
81 for i
in range(model.nbodies):
82 self.assertApprox(data.v[i].np,
zero(6))
83 self.assertApprox(data.a_gf[0].np, -model.gravity.np)
84 self.assertApprox(data.f[-1], model.inertias[-1] * data.a_gf[-1])
88 model.referenceConfigurations[
"neutral"] = pin.neutral(model)
89 q_neutral = model.referenceConfigurations[
"neutral"]
92 self.assertApprox(model.referenceConfigurations[
"neutral"],q_neutral)
98 filename =
"model.pickle" 99 with
open(filename,
'wb')
as f:
102 with
open(filename,
'rb')
as f:
103 model_copy = pickle.load(f)
105 self.assertTrue(model == model_copy)
107 if __name__ ==
'__main__':
def test_placements(self)
def test_empty_model_sizes(self)
def test_std_map_fields(self)