bindings_inverse_dynamics_derivatives.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 TestDeriavtives(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 
23 
24  res = pin.computeRNEADerivatives(self.model,self.data,self.q,self.v,self.a)
25 
26  self.assertTrue(len(res) == 3)
27 
28  data2 = self.model.createData()
29  pin.rnea(self.model,data2,self.q,self.v,self.a)
30 
31  self.assertApprox(self.data.ddq,data2.ddq)
32 
33  # With external forces
34  res = pin.computeRNEADerivatives(self.model,self.data,self.q,self.v,self.a,self.fext)
35 
36  self.assertTrue(len(res) == 3)
37 
38  pin.rnea(self.model,data2,self.q,self.v,self.a,self.fext)
39 
40  self.assertApprox(self.data.ddq,data2.ddq)
41 
43 
44  res = pin.computeGeneralizedGravityDerivatives(self.model,self.data,self.q)
45 
46  data2 = self.model.createData()
47  ref,_,_ = pin.computeRNEADerivatives(self.model,data2,self.q,self.v*0,self.a*0)
48 
49  self.assertApprox(res,ref)
50 
52 
53  res = pin.computeStaticTorqueDerivatives(self.model,self.data,self.q,self.fext)
54 
55  data2 = self.model.createData()
56  ref,_,_ = pin.computeRNEADerivatives(self.model,data2,self.q,self.v*0,self.a*0,self.fext)
57 
58  self.assertApprox(res,ref)
59 
60 if __name__ == '__main__':
61  unittest.main()


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