bindings_frame_derivatives.py
Go to the documentation of this file.
1 import unittest
2 
3 import numpy as np
4 import pinocchio as pin
5 from test_case import PinocchioTestCase
6 
7 
9  def setUp(self):
10  self.model = pin.buildSampleModelHumanoidRandom()
11  self.parent_idx = (
12  self.model.getJointId("rarm2_joint")
13  if self.model.existJointName("rarm2_joint")
14  else (self.model.njoints - 1)
15  )
16  self.frame_name = self.model.names[self.parent_idx] + "_frame"
17  self.frame_placement = pin.SE3.Random()
18  self.frame_type = pin.FrameType.OP_FRAME
19  self.model.addFrame(
20  pin.Frame(
21  self.frame_name,
22  self.parent_idx,
23  0,
24  self.frame_placement,
25  self.frame_type,
26  )
27  )
28  self.frame_idx = self.model.getFrameId(self.frame_name)
29 
30  self.data = self.model.createData()
31  self.q = pin.randomConfiguration(self.model)
32  self.v = np.random.rand(self.model.nv)
33  self.a = np.random.rand(self.model.nv)
34 
35  def tearDown(self):
36  del self.model
37 
38  def test_derivatives(self):
39  model = self.model
40  data = self.data
41 
42  q = self.q
43  v = self.v
44  a = self.a
45 
46  pin.computeForwardKinematicsDerivatives(model, data, q, v, a)
47 
48  pin.getFrameVelocityDerivatives(model, data, self.frame_idx, pin.WORLD)
49  pin.getFrameVelocityDerivatives(model, data, self.frame_idx, pin.LOCAL)
50  pin.getFrameVelocityDerivatives(
51  model, data, self.frame_idx, pin.LOCAL_WORLD_ALIGNED
52  )
53 
54  pin.getFrameAccelerationDerivatives(model, data, self.frame_idx, pin.WORLD)
55  pin.getFrameAccelerationDerivatives(model, data, self.frame_idx, pin.LOCAL)
56  pin.getFrameAccelerationDerivatives(
57  model, data, self.frame_idx, pin.LOCAL_WORLD_ALIGNED
58  )
59 
60 
61 if __name__ == "__main__":
62  unittest.main()
bindings_frame_derivatives.TestFrameBindings.frame_name
frame_name
Definition: bindings_frame_derivatives.py:16
bindings_frame_derivatives.TestFrameBindings.data
data
Definition: bindings_frame_derivatives.py:30
bindings_frame_derivatives.TestFrameBindings.tearDown
def tearDown(self)
Definition: bindings_frame_derivatives.py:35
bindings_frame_derivatives.TestFrameBindings.setUp
def setUp(self)
Definition: bindings_frame_derivatives.py:9
bindings_frame_derivatives.TestFrameBindings.a
a
Definition: bindings_frame_derivatives.py:33
bindings_frame_derivatives.TestFrameBindings
Definition: bindings_frame_derivatives.py:8
bindings_frame_derivatives.TestFrameBindings.v
v
Definition: bindings_frame_derivatives.py:32
bindings_frame_derivatives.TestFrameBindings.q
q
Definition: bindings_frame_derivatives.py:31
bindings_frame_derivatives.TestFrameBindings.frame_placement
frame_placement
Definition: bindings_frame_derivatives.py:17
bindings_frame_derivatives.TestFrameBindings.model
model
Definition: bindings_frame_derivatives.py:10
pinocchio::createData
ConstraintDataTpl< Scalar, Options, ConstraintCollectionTpl > createData(const ConstraintModelTpl< Scalar, Options, ConstraintCollectionTpl > &cmodel)
Definition: constraint-model-visitor.hpp:239
bindings_frame_derivatives.TestFrameBindings.parent_idx
parent_idx
Definition: bindings_frame_derivatives.py:11
bindings_frame_derivatives.TestFrameBindings.test_derivatives
def test_derivatives(self)
Definition: bindings_frame_derivatives.py:38
test_case.PinocchioTestCase
Definition: test_case.py:11
bindings_frame_derivatives.TestFrameBindings.frame_idx
frame_idx
Definition: bindings_frame_derivatives.py:28
bindings_frame_derivatives.TestFrameBindings.frame_type
frame_type
Definition: bindings_frame_derivatives.py:18


pinocchio
Author(s):
autogenerated on Thu Dec 19 2024 03:41:25