unittest
python
bindings_forward_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.
tau
= 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_derivatives
(self):
23
res = pin.computeABADerivatives(self.
model
,self.
data
,self.
q
,self.
v
,self.
tau
)
24
25
self.assertTrue(len(res) == 3)
26
27
data2 = self.
model
.
createData
()
28
pin.aba(self.
model
,data2,self.
q
,self.
v
,self.
tau
)
29
30
self.assertApprox(self.
data
.ddq,data2.ddq)
31
32
# With external forces
33
res = pin.computeABADerivatives(self.
model
,self.
data
,self.
q
,self.
v
,self.
tau
,self.
fext
)
34
35
self.assertTrue(len(res) == 3)
36
37
pin.aba(self.
model
,data2,self.
q
,self.
v
,self.
tau
,self.
fext
)
38
39
self.assertApprox(self.
data
.ddq,data2.ddq)
40
41
if
__name__ ==
'__main__'
:
42
unittest.main()
boost::fusion::append
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
bindings_forward_dynamics_derivatives.TestDeriavtives.model
model
Definition:
bindings_forward_dynamics_derivatives.py:10
bindings_forward_dynamics_derivatives.TestDeriavtives
Definition:
bindings_forward_dynamics_derivatives.py:7
pinocchio::createData
JointDataTpl< Scalar, Options, JointCollectionTpl > createData(const JointModelTpl< Scalar, Options, JointCollectionTpl > &jmodel)
Visit a JointModelTpl through CreateData visitor to create a JointDataTpl.
bindings_forward_dynamics_derivatives.TestDeriavtives.q
q
Definition:
bindings_forward_dynamics_derivatives.py:14
bindings_forward_dynamics_derivatives.TestDeriavtives.data
data
Definition:
bindings_forward_dynamics_derivatives.py:11
bindings_forward_dynamics_derivatives.TestDeriavtives.test_aba_derivatives
def test_aba_derivatives(self)
Definition:
bindings_forward_dynamics_derivatives.py:22
bindings_forward_dynamics_derivatives.TestDeriavtives.setUp
def setUp(self)
Definition:
bindings_forward_dynamics_derivatives.py:9
bindings_forward_dynamics_derivatives.TestDeriavtives.tau
tau
Definition:
bindings_forward_dynamics_derivatives.py:16
bindings_forward_dynamics_derivatives.TestDeriavtives.fext
fext
Definition:
bindings_forward_dynamics_derivatives.py:18
bindings_forward_dynamics_derivatives.TestDeriavtives.v
v
Definition:
bindings_forward_dynamics_derivatives.py:15
pinocchio
Author(s):
autogenerated on Fri Jun 23 2023 02:38:28