bindings_aba.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 TestABA(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.ddq = 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_aba(self):
23  model = self.model
24  ddq = pin.aba(self.model,self.data,self.q,self.v,self.ddq)
25 
26  null_fext = pin.StdVec_Force()
27  for _ in range(model.njoints):
28  null_fext.append(pin.Force.Zero())
29 
30  ddq_null_fext = pin.aba(self.model,self.data,self.q,self.v,self.ddq,null_fext)
31  self.assertApprox(ddq_null_fext,ddq)
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  ddq_null_fext_list = pin.aba(self.model,self.data,self.q,self.v,self.ddq,null_fext_list)
39  self.assertApprox(ddq_null_fext_list,ddq)
40 
42  model = self.model
43  Minv = pin.computeMinverse(model,self.data,self.q)
44 
45  data2 = model.createData()
46  M = pin.crba(model,data2,self.q)
47 
48  self.assertApprox(np.linalg.inv(M),Minv)
49 
50 if __name__ == '__main__':
51  unittest.main()
result_of::push_front< V const, T >::type append(T const &t, V const &v)
Append the element T at the front of boost fusion vector V.
Definition: fusion.hpp:24
JointDataTpl< Scalar, Options, JointCollectionTpl > createData(const JointModelTpl< Scalar, Options, JointCollectionTpl > &jmodel)
Visit a JointModelTpl through CreateData visitor to create a JointDataTpl.
def test_computeMinverse(self)
Definition: bindings_aba.py:41


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