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()
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)
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)
57  model, data, self.frame_idx, pin.LOCAL_WORLD_ALIGNED
58  )
59 
60 
61 if __name__ == "__main__":
62  unittest.main()
pinocchio::getFrameVelocityDerivatives
void getFrameVelocityDerivatives(const ModelTpl< Scalar, Options, JointCollectionTpl > &model, DataTpl< Scalar, Options, JointCollectionTpl > &data, const FrameIndex frame_id, const ReferenceFrame rf, const Eigen::MatrixBase< Matrix6xOut1 > &v_partial_dq, const Eigen::MatrixBase< Matrix6xOut2 > &v_partial_dv)
Computes the partial derivatives of the frame spatial velocity with respect to q and v....
Definition: frames-derivatives.hpp:74
pinocchio::getFrameAccelerationDerivatives
void getFrameAccelerationDerivatives(const ModelTpl< Scalar, Options, JointCollectionTpl > &model, DataTpl< Scalar, Options, JointCollectionTpl > &data, const FrameIndex frame_id, const ReferenceFrame rf, const Eigen::MatrixBase< Matrix6xOut1 > &v_partial_dq, const Eigen::MatrixBase< Matrix6xOut2 > &v_partial_dv, const Eigen::MatrixBase< Matrix6xOut3 > &a_partial_dq, const Eigen::MatrixBase< Matrix6xOut4 > &a_partial_dv, const Eigen::MatrixBase< Matrix6xOut5 > &a_partial_da)
Computes the partial derivatives of the frame acceleration quantity with respect to q,...
Definition: frames-derivatives.hpp:309
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
pinocchio::randomConfiguration
void randomConfiguration(const LieGroupGenericTpl< LieGroupCollection > &lg, const Eigen::MatrixBase< ConfigL_t > &q0, const Eigen::MatrixBase< ConfigR_t > &q1, const Eigen::MatrixBase< ConfigOut_t > &qout)
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
pinocchio::FrameTpl
A Plucker coordinate frame attached to a parent joint inside a kinematic tree.
Definition: multibody/frame.hpp:55
bindings_frame_derivatives.TestFrameBindings.frame_placement
frame_placement
Definition: bindings_frame_derivatives.py:17
pinocchio::computeForwardKinematicsDerivatives
void computeForwardKinematicsDerivatives(const ModelTpl< Scalar, Options, JointCollectionTpl > &model, DataTpl< Scalar, Options, JointCollectionTpl > &data, const Eigen::MatrixBase< ConfigVectorType > &q, const Eigen::MatrixBase< TangentVectorType1 > &v, const Eigen::MatrixBase< TangentVectorType2 > &a)
Computes all the terms required to compute the derivatives of the placement, spatial velocity and acc...
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 Wed May 28 2025 02:41:14