joint-motion-subspace-generic.hpp
Go to the documentation of this file.
1 //
2 // Copyright (c) 2015-2020 CNRS INRIA
3 // Copyright (c) 2016 Wandercraft, 86 rue de Paris 91400 Orsay, France.
4 //
5 
6 #ifndef __pinocchio_multibody_constraint_generic_hpp__
7 #define __pinocchio_multibody_constraint_generic_hpp__
8 
9 namespace pinocchio
10 {
11 
12  template<int _Dim, typename _Scalar, int _Options>
13  struct traits<JointMotionSubspaceTpl<_Dim, _Scalar, _Options>>
14  {
15  typedef _Scalar Scalar;
16  enum
17  {
18  LINEAR = 0,
19  ANGULAR = 3,
20  Options = _Options,
21  Dim = _Dim
22  };
23 
25  typedef Eigen::Matrix<Scalar, Dim, 1, Options> JointForce;
26  typedef Eigen::Matrix<Scalar, 6, Dim, Options> DenseBase;
27  typedef Eigen::Matrix<Scalar, Dim, Dim, Options> ReducedSquaredMatrix;
28 
29  typedef typename PINOCCHIO_EIGEN_REF_CONST_TYPE(DenseBase) ConstMatrixReturnType;
30  typedef typename PINOCCHIO_EIGEN_REF_TYPE(DenseBase) MatrixReturnType;
31 
33  }; // traits JointMotionSubspaceTpl
34 
35  template<int Dim, typename Scalar, int Options>
37  {
38  typedef Eigen::Matrix<Scalar, 6, Dim> ReturnType;
39  };
40 
41  template<int Dim, typename Scalar, int Options, typename MotionDerived>
43  {
44  typedef Eigen::Matrix<Scalar, 6, Dim> ReturnType;
45  };
46 
47  template<int _Dim, typename _Scalar, int _Options>
49  : public JointMotionSubspaceBase<JointMotionSubspaceTpl<_Dim, _Scalar, _Options>>
50  {
51  EIGEN_MAKE_ALIGNED_OPERATOR_NEW
52 
54 
57 
58  enum
59  {
60  NV = _Dim
61  };
62 
63  using Base::nv;
64 
65  template<typename D>
66  explicit JointMotionSubspaceTpl(const Eigen::MatrixBase<D> & _S)
67  : S(_S)
68  {
69  // There is currently a bug in Eigen/Core/util/StaticAssert.h in the use of the full namespace
70  // path
71  // TODO
72  EIGEN_STATIC_ASSERT_SAME_MATRIX_SIZE(DenseBase, D);
73  }
74 
76  : S()
77  {
78  EIGEN_STATIC_ASSERT(
79  _Dim != Eigen::Dynamic, YOU_CALLED_A_DYNAMIC_SIZE_METHOD_ON_A_FIXED_SIZE_MATRIX_OR_VECTOR)
80  }
81 
82  // It is only valid for dynamics size
83  explicit JointMotionSubspaceTpl(const int dim)
84  : S(6, dim)
85  {
86  EIGEN_STATIC_ASSERT(
87  _Dim == Eigen::Dynamic, YOU_CALLED_A_FIXED_SIZE_METHOD_ON_A_DYNAMIC_SIZE_MATRIX_OR_VECTOR)
88  }
89 
90  static JointMotionSubspaceTpl Zero(const int dim)
91  {
93  }
94 
95  template<typename VectorLike>
96  JointMotion __mult__(const Eigen::MatrixBase<VectorLike> & vj) const
97  {
98  return JointMotion(S * vj);
99  }
100 
101  struct Transpose : JointMotionSubspaceTransposeBase<JointMotionSubspaceTpl>
102  {
105  : ref(ref)
106  {
107  }
108 
109  template<typename Derived>
110  JointForce operator*(const ForceDense<Derived> & f) const
111  {
112  return (ref.S.transpose() * f.toVector()).eval();
113  }
114 
115  template<typename D>
116  typename Eigen::Matrix<Scalar, NV, Eigen::Dynamic> operator*(const Eigen::MatrixBase<D> & F)
117  {
118  return (ref.S.transpose() * F).eval();
119  }
120  };
121 
123  {
124  return Transpose(*this);
125  }
126 
127  MatrixReturnType matrix_impl()
128  {
129  return S;
130  }
131  ConstMatrixReturnType matrix_impl() const
132  {
133  return S;
134  }
135 
136  int nv_impl() const
137  {
138  return (int)S.cols();
139  }
140 
141  template<typename S2, int O2>
144  {
145  typedef typename JointMotionSubspaceTpl::DenseBase ReturnType;
146  ReturnType res(6, S.nv());
148  return res;
149  }
150 
151  template<typename S2, int O2>
152  friend Eigen::Matrix<_Scalar, 6, _Dim>
153  operator*(const Eigen::Matrix<S2, 6, 6, O2> & Ymatrix, const JointMotionSubspaceTpl & S)
154  {
155  typedef Eigen::Matrix<_Scalar, 6, _Dim> ReturnType;
156  return ReturnType(Ymatrix * S.matrix());
157  }
158 
159  DenseBase se3Action(const SE3Tpl<Scalar, Options> & m) const
160  {
161  DenseBase res(6, nv());
163  return res;
164  }
165 
166  DenseBase se3ActionInverse(const SE3Tpl<Scalar, Options> & m) const
167  {
168  DenseBase res(6, nv());
170  return res;
171  }
172 
173  template<typename MotionDerived>
174  DenseBase motionAction(const MotionDense<MotionDerived> & v) const
175  {
176  DenseBase res(6, nv());
178  return res;
179  }
180 
181  void disp_impl(std::ostream & os) const
182  {
183  os << "S =\n" << S << std::endl;
184  }
185 
186  bool isEqual(const JointMotionSubspaceTpl & other) const
187  {
188  return S == other.S;
189  }
190 
191  protected:
192  DenseBase S;
193  }; // class JointMotionSubspaceTpl
194 
195  namespace details
196  {
197  template<int Dim, typename Scalar, int Options>
199  {
202 
204  {
205  return constraint.matrix().transpose() * constraint.matrix();
206  }
207  };
208  } // namespace details
209 
210 } // namespace pinocchio
211 
212 #endif // ifndef __pinocchio_multibody_constraint_generic_hpp__
pinocchio::traits< JointMotionSubspaceTpl< _Dim, _Scalar, _Options > >::ReducedSquaredMatrix
Eigen::Matrix< Scalar, Dim, Dim, Options > ReducedSquaredMatrix
Definition: joint-motion-subspace-generic.hpp:27
pinocchio::InertiaTpl
Definition: spatial/fwd.hpp:58
pinocchio::traits< JointMotionSubspaceTpl< _Dim, _Scalar, _Options > >::JointMotion
MotionTpl< Scalar, Options > JointMotion
Definition: joint-motion-subspace-generic.hpp:24
pinocchio::JointMotionSubspaceBase< JointMotionSubspaceTpl< _Dim, _Scalar, _Options > >::nv
int nv() const
Definition: joint-motion-subspace-base.hpp:91
pinocchio::details::StDiagonalMatrixSOperation< JointMotionSubspaceTpl< Dim, Scalar, Options > >::Constraint
JointMotionSubspaceTpl< Dim, Scalar, Options > Constraint
Definition: joint-motion-subspace-generic.hpp:200
test-cpp2pybind11.m
m
Definition: test-cpp2pybind11.py:25
pinocchio::traits< JointMotionSubspaceTpl< _Dim, _Scalar, _Options > >::Scalar
_Scalar Scalar
Definition: joint-motion-subspace-generic.hpp:15
pinocchio::JointMotionSubspaceTpl::operator*
friend Eigen::Matrix< _Scalar, 6, _Dim > operator*(const Eigen::Matrix< S2, 6, 6, O2 > &Ymatrix, const JointMotionSubspaceTpl &S)
Definition: joint-motion-subspace-generic.hpp:153
pinocchio::motionSet::inertiaAction
static void inertiaAction(const InertiaTpl< Scalar, Options > &I, const Eigen::MatrixBase< Mat > &iF, Eigen::MatrixBase< MatRet > const &jF)
Action of an Inertia matrix on a set of motions, represented by a 6xN matrix whose columns represent ...
pinocchio::JointMotionSubspaceTpl::JointMotionSubspaceTpl
JointMotionSubspaceTpl(const int dim)
Definition: joint-motion-subspace-generic.hpp:83
pinocchio::JointMotionSubspaceTpl::matrix_impl
ConstMatrixReturnType matrix_impl() const
Definition: joint-motion-subspace-generic.hpp:131
pinocchio::Options
Options
Definition: joint-configuration.hpp:1082
pinocchio::JointMotionSubspaceTpl::JointMotionSubspaceTpl
JointMotionSubspaceTpl(const Eigen::MatrixBase< D > &_S)
Definition: joint-motion-subspace-generic.hpp:66
pinocchio::motionSet::motionAction
static void motionAction(const MotionDense< MotionDerived > &v, const Eigen::MatrixBase< Mat > &iF, Eigen::MatrixBase< MatRet > const &jF)
Action of a motion on a set of motions, represented by a 6xN matrix whose columns represent a spatial...
pinocchio::JointMotionSubspaceBase
Definition: joint-motion-subspace-base.hpp:59
pinocchio::traits< JointMotionSubspaceTpl< _Dim, _Scalar, _Options > >::JointForce
Eigen::Matrix< Scalar, Dim, 1, Options > JointForce
Definition: joint-motion-subspace-generic.hpp:25
pinocchio::SE3Tpl< Scalar, Options >
pinocchio::JointMotionSubspaceTpl::Zero
static JointMotionSubspaceTpl Zero(const int dim)
Definition: joint-motion-subspace-generic.hpp:90
pinocchio::PINOCCHIO_EIGEN_REF_CONST_TYPE
PINOCCHIO_EIGEN_REF_CONST_TYPE(Matrix6Like) operator*(const Eigen
Definition: joint-free-flyer.hpp:144
pinocchio::details::StDiagonalMatrixSOperation< JointMotionSubspaceTpl< Dim, Scalar, Options > >::run
static ReturnType run(const JointMotionSubspaceBase< Constraint > &constraint)
Definition: joint-motion-subspace-generic.hpp:203
pinocchio::JointMotionSubspaceTpl::matrix_impl
MatrixReturnType matrix_impl()
Definition: joint-motion-subspace-generic.hpp:127
pinocchio::JointMotionSubspaceTpl::__mult__
JointMotion __mult__(const Eigen::MatrixBase< VectorLike > &vj) const
Definition: joint-motion-subspace-generic.hpp:96
pinocchio::JointMotionSubspaceTpl::Base
EIGEN_MAKE_ALIGNED_OPERATOR_NEW typedef JointMotionSubspaceBase< JointMotionSubspaceTpl > Base
Definition: joint-motion-subspace-generic.hpp:53
pinocchio::MotionDense
Definition: context/casadi.hpp:36
pinocchio::python::Scalar
context::Scalar Scalar
Definition: admm-solver.cpp:29
pinocchio::res
ReturnType res
Definition: spatial/classic-acceleration.hpp:57
pinocchio::JointMotionSubspaceTpl::Transpose
Definition: joint-motion-subspace-generic.hpp:101
pinocchio::MotionAlgebraAction
Return type of the ation of a Motion onto an object of type D.
Definition: spatial/motion.hpp:45
autodiff-rnea.f
f
Definition: autodiff-rnea.py:24
pinocchio::motionSet::se3ActionInverse
static void se3ActionInverse(const SE3Tpl< Scalar, Options > &m, const Eigen::MatrixBase< Mat > &iV, Eigen::MatrixBase< MatRet > const &jV)
Inverse SE3 action on a set of motions, represented by a 6xN matrix whose column represent a spatial ...
pinocchio::JointMotionSubspaceTpl::S
DenseBase S
Definition: joint-motion-subspace-generic.hpp:192
pinocchio::JointMotionSubspaceTpl::nv_impl
int nv_impl() const
Definition: joint-motion-subspace-generic.hpp:136
pinocchio::JointMotionSubspaceTpl::disp_impl
void disp_impl(std::ostream &os) const
Definition: joint-motion-subspace-generic.hpp:181
pinocchio::SE3GroupAction
Definition: spatial/se3.hpp:39
pinocchio::JointMotionSubspaceTpl::Transpose::operator*
Eigen::Matrix< Scalar, NV, Eigen::Dynamic > operator*(const Eigen::MatrixBase< D > &F)
Definition: joint-motion-subspace-generic.hpp:116
pinocchio::JointMotionSubspaceBase::matrix
MatrixReturnType matrix()
Definition: joint-motion-subspace-base.hpp:82
pinocchio::JointMotionSubspaceTpl::NV
@ NV
Definition: joint-motion-subspace-generic.hpp:60
pinocchio::JointMotionSubspaceTpl::JointMotionSubspaceTpl
JointMotionSubspaceTpl()
Definition: joint-motion-subspace-generic.hpp:75
details
pinocchio::JointMotionSubspaceTpl::motionAction
DenseBase motionAction(const MotionDense< MotionDerived > &v) const
Definition: joint-motion-subspace-generic.hpp:174
pinocchio::JointMotionSubspaceTpl::transpose
Transpose transpose() const
Definition: joint-motion-subspace-generic.hpp:122
pinocchio::Dynamic
const int Dynamic
Definition: fwd.hpp:140
D
D
pinocchio::JointMotionSubspaceTpl::operator*
friend JointMotionSubspaceTpl< _Dim, _Scalar, _Options >::DenseBase operator*(const InertiaTpl< S2, O2 > &Y, const JointMotionSubspaceTpl &S)
Definition: joint-motion-subspace-generic.hpp:143
pinocchio::details::StDiagonalMatrixSOperation< JointMotionSubspaceTpl< Dim, Scalar, Options > >::ReturnType
traits< Constraint >::StDiagonalMatrixSOperationReturnType ReturnType
Definition: joint-motion-subspace-generic.hpp:201
pinocchio::JointMotionSubspaceTpl::se3ActionInverse
DenseBase se3ActionInverse(const SE3Tpl< Scalar, Options > &m) const
Definition: joint-motion-subspace-generic.hpp:166
pinocchio::JointMotionSubspaceTpl::isEqual
bool isEqual(const JointMotionSubspaceTpl &other) const
Definition: joint-motion-subspace-generic.hpp:186
pinocchio::MotionAlgebraAction< JointMotionSubspaceTpl< Dim, Scalar, Options >, MotionDerived >::ReturnType
Eigen::Matrix< Scalar, 6, Dim > ReturnType
Definition: joint-motion-subspace-generic.hpp:44
pinocchio::v
JointCollectionTpl const Eigen::MatrixBase< ConfigVectorType > const Eigen::MatrixBase< TangentVectorType > & v
Definition: joint-configuration.hpp:1084
pinocchio::JointMotionSubspaceTpl::Transpose::Transpose
Transpose(const JointMotionSubspaceTpl &ref)
Definition: joint-motion-subspace-generic.hpp:104
pinocchio::ForceDense
Definition: context/casadi.hpp:34
pinocchio::traits< JointMotionSubspaceTpl< _Dim, _Scalar, _Options > >::DenseBase
Eigen::Matrix< Scalar, 6, Dim, Options > DenseBase
Definition: joint-motion-subspace-generic.hpp:26
pinocchio::details::StDiagonalMatrixSOperation
Definition: joint-motion-subspace-base.hpp:172
PINOCCHIO_CONSTRAINT_TYPEDEF_TPL
#define PINOCCHIO_CONSTRAINT_TYPEDEF_TPL(DERIVED)
Definition: joint-motion-subspace-base.hpp:36
Y
Y
codegen-rnea.nv
nv
Definition: codegen-rnea.py:19
pinocchio::traits
Common traits structure to fully define base classes for CRTP.
Definition: fwd.hpp:71
pinocchio::JointMotionSubspaceTpl::Transpose::ref
const JointMotionSubspaceTpl & ref
Definition: joint-motion-subspace-generic.hpp:103
PINOCCHIO_EIGEN_REF_TYPE
#define PINOCCHIO_EIGEN_REF_TYPE(D)
Definition: eigen-macros.hpp:32
pinocchio::JointMotionSubspaceTpl::Transpose::operator*
JointForce operator*(const ForceDense< Derived > &f) const
Definition: joint-motion-subspace-generic.hpp:110
dim
int dim
pinocchio::motionSet::se3Action
static void se3Action(const SE3Tpl< Scalar, Options > &m, const Eigen::MatrixBase< Mat > &iV, Eigen::MatrixBase< MatRet > const &jV)
SE3 action on a set of motions, represented by a 6xN matrix whose column represent a spatial motion.
pinocchio::JointMotionSubspaceTransposeBase
Definition: joint-motion-subspace-base.hpp:185
pinocchio::MotionTpl< Scalar, Options >
pinocchio::JointMotionSubspaceTpl::se3Action
DenseBase se3Action(const SE3Tpl< Scalar, Options > &m) const
Definition: joint-motion-subspace-generic.hpp:159
pinocchio::traits< JointMotionSubspaceTpl< _Dim, _Scalar, _Options > >::StDiagonalMatrixSOperationReturnType
ReducedSquaredMatrix StDiagonalMatrixSOperationReturnType
Definition: joint-motion-subspace-generic.hpp:32
pinocchio::JointMotionSubspaceTpl
Definition: joint-motion-subspace-generic.hpp:48
pinocchio::SE3GroupAction< JointMotionSubspaceTpl< Dim, Scalar, Options > >::ReturnType
Eigen::Matrix< Scalar, 6, Dim > ReturnType
Definition: joint-motion-subspace-generic.hpp:38
pinocchio
Main pinocchio namespace.
Definition: timings.cpp:27


pinocchio
Author(s):
autogenerated on Sun Nov 10 2024 03:42:59