bindings_rnea.py
Go to the documentation of this file.
1 import unittest
2 from test_case import PinocchioTestCase as TestCase
3 
4 import pinocchio as pin
5 import numpy as np
6 
7 class TestRNEA(TestCase):
8 
9  def setUp(self):
10  self.model = pin.buildSampleModelHumanoidRandom()
11  self.data = self.model.createData()
12 
13  qmax = np.full((self.model.nq,1),np.pi)
14  self.q = pin.randomConfiguration(self.model,-qmax,qmax)
15  self.v = np.random.rand(self.model.nv)
16  self.a = np.random.rand(self.model.nv)
17 
18  self.fext = []
19  for _ in range(self.model.njoints):
20  self.fext.append(pin.Force.Random())
21 
22  def test_rnea(self):
23  model = self.model
24  tau = pin.rnea(self.model,self.data,self.q,self.v,self.a)
25 
26  null_fext = pin.StdVec_Force()
27  for k in range(model.njoints):
28  null_fext.append(pin.Force.Zero())
29 
30  tau_null_fext = pin.rnea(self.model,self.data,self.q,self.v,self.a,null_fext)
31  self.assertApprox(tau_null_fext,tau)
32 
33  null_fext_list = []
34  for f in null_fext:
35  null_fext_list.append(f)
36 
37  print('size:',len(null_fext_list))
38  tau_null_fext_list = pin.rnea(self.model,self.data,self.q,self.v,self.a,null_fext_list)
39  self.assertApprox(tau_null_fext_list,tau)
40 
41  def test_nle(self):
42  model = self.model
43 
44  tau = pin.nonLinearEffects(model,self.data,self.q,self.v)
45 
46  data2 = model.createData()
47  tau_ref = pin.rnea(model,data2,self.q,self.v,self.a*0)
48 
49  self.assertApprox(tau,tau_ref)
50 
52  model = self.model
53 
54  tau = pin.computeGeneralizedGravity(model,self.data,self.q)
55 
56  data2 = model.createData()
57  tau_ref = pin.rnea(model,data2,self.q,self.v*0,self.a*0)
58 
59  self.assertApprox(tau,tau_ref)
60 
61  def test_static_torque(self):
62  model = self.model
63 
64  tau = pin.computeStaticTorque(model,self.data,self.q,self.fext)
65 
66  data2 = model.createData()
67  tau_ref = pin.rnea(model,data2,self.q,self.v*0,self.a*0,self.fext)
68 
69  self.assertApprox(tau,tau_ref)
70 
72  model = self.model
73 
74  C = pin.computeCoriolisMatrix(model,self.data,self.q,self.v)
75 
76  data2 = model.createData()
77  tau_coriolis_ref = pin.rnea(model,data2,self.q,self.v,self.a*0) - pin.rnea(model,data2,self.q,self.v*0,self.a*0)
78 
79  self.assertApprox(tau_coriolis_ref,C.dot(self.v))
80 
81 if __name__ == '__main__':
82  unittest.main()
def test_static_torque(self)
def test_coriolis_matrix(self)
def test_generalized_gravity(self)


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