19 #ifndef __se3_joint_prismatic_unaligned_hpp__ 20 #define __se3_joint_prismatic_unaligned_hpp__ 22 #include "pinocchio/macros.hpp" 23 #include "pinocchio/multibody/joint/joint-base.hpp" 24 #include "pinocchio/multibody/constraint.hpp" 25 #include "pinocchio/spatial/inertia.hpp" 32 template<
typename _Scalar,
int _Options>
35 typedef _Scalar Scalar;
36 enum { Options = _Options };
37 typedef Eigen::Matrix<Scalar,3,1,Options> Vector3;
38 typedef Eigen::Matrix<Scalar,6,1,Options> Vector6;
39 typedef Eigen::Matrix<Scalar,6,6,Options> Matrix6;
40 typedef typename EIGEN_REF_CONSTTYPE(Vector6) ToVectorConstReturnType;
41 typedef typename EIGEN_REF_TYPE(Vector6) ToVectorReturnType;
42 typedef Vector3 AngularType;
43 typedef Vector3 LinearType;
44 typedef const Vector3 ConstAngularType;
45 typedef const Vector3 ConstLinearType;
46 typedef Matrix6 ActionMatrixType;
54 template<
typename _Scalar,
int _Options>
61 template<
typename Vector3Like,
typename S2>
63 : axis(axis), rate(rate)
64 { EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(Vector3Like,3); }
67 {
return MotionPlain(axis*rate,MotionPlain::Vector3::Zero());}
69 template<
typename Derived>
72 v.linear() += axis * rate;
80 template<
typename Scalar,
int Options,
typename MotionDerived>
81 inline typename MotionDerived::MotionPlain
84 typedef typename MotionDerived::MotionPlain ReturnType;
85 return ReturnType(m1.rate*m1.axis + m2.linear(), m2.angular());
90 template<
typename _Scalar,
int _Options>
93 typedef _Scalar Scalar;
94 enum { Options = _Options };
95 typedef Eigen::Matrix<Scalar,3,1,Options> Vector3;
96 typedef Eigen::Matrix<Scalar,4,1,Options> Vector4;
97 typedef Eigen::Matrix<Scalar,6,1,Options> Vector6;
98 typedef Eigen::Matrix<Scalar,3,3,Options> Matrix3;
99 typedef Eigen::Matrix<Scalar,4,4,Options> Matrix4;
100 typedef Eigen::Matrix<Scalar,6,6,Options> Matrix6;
101 typedef Matrix3 Angular_t;
102 typedef Vector3 Linear_t;
103 typedef const Matrix3 ConstAngular_t;
104 typedef const Vector3 ConstLinear_t;
105 typedef Matrix6 ActionMatrix_t;
106 typedef Eigen::Quaternion<Scalar,Options> Quaternion_t;
115 typedef Eigen::Matrix<Scalar,1,1,Options> JointMotion;
116 typedef Eigen::Matrix<Scalar,1,1,Options> JointForce;
117 typedef Eigen::Matrix<Scalar,6,1,Options> DenseBase;
118 typedef DenseBase MatrixReturnType;
119 typedef const DenseBase ConstMatrixReturnType;
122 template<
typename _Scalar,
int _Options>
127 enum { NV = 1, Options = _Options };
134 template<
typename Vector3Like>
137 { EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(Vector3Like,3); }
139 template<
typename Derived>
142 EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(Derived,1);
146 template<
typename S1,
int O1>
150 res.template head<3>().noalias() = m.rotation()*axis;
151 res.template tail<3>().setZero();
155 int nv_impl()
const {
return NV; }
166 template<
typename Derived>
172 typedef Eigen::Matrix<
176 ReturnType res; res[0] = ref.axis.dot(f.
linear());
183 #if EIGEN_VERSION_AT_LEAST(3,2,90) 184 const Eigen::Product<
185 Eigen::Transpose<const Vector3>,
186 typename Eigen::MatrixBase<const D>::template NRowsBlockXpr<3>::Type
189 const typename Eigen::ProductReturnType<
190 Eigen::Transpose<const Vector3>,
191 typename Eigen::MatrixBase<const D>::template NRowsBlockXpr<3>::Type
194 operator* (
const TransposeConst & tc,
const Eigen::MatrixBase<D> & F)
196 EIGEN_STATIC_ASSERT(D::RowsAtCompileTime==6,THIS_METHOD_IS_ONLY_FOR_MATRICES_OF_A_SPECIFIC_SIZE)
198 return tc.ref.axis.transpose () * F.template topRows<3> ();
211 DenseBase matrix_impl()
const 214 S << axis, Vector3::Zero();
218 template<
typename MotionDerived>
222 res << v.angular().cross(axis), Vector3::Zero();
233 template<
typename MotionDerived,
typename S2,
int O2>
234 inline typename MotionDerived::MotionPlain
238 typedef typename MotionDerived::MotionPlain ReturnType;
240 const typename MotionDerived::ConstAngularType & w1 = m1.angular();
242 return ReturnType(w1.cross(v2), ReturnType::Vector3::Zero());
246 template<
typename S1,
int O1,
typename S2,
int O2>
247 inline Eigen::Matrix<S1,6,1>
252 const S1 & m = Y.mass();
253 const typename Inertia::Vector3 & c = Y.lever();
255 Eigen::Matrix<S1,6,1> res;
256 res.template head<3>().noalias() = m*cpu.axis;
257 res.template tail<3>() = c.cross(res.template head<3>());
262 template<
typename M6,
typename S2,
int O2>
263 #if EIGEN_VERSION_AT_LEAST(3,2,90) 264 const typename Eigen::Product<
265 Eigen::Block<const M6,6,3>,
267 Eigen::DefaultProduct>
269 const typename Eigen::ProductReturnType<
270 Eigen::Block<const M6,6,3>,
271 const typename ConstraintPrismaticUnaligned<S2,O2>::Vector3
276 EIGEN_STATIC_ASSERT_MATRIX_SPECIFIC_SIZE(M6,6,6);
277 return Y.template block<6,3> (0,Inertia::LINEAR) * cpu.axis;
283 template<
typename Scalar,
int Options>
284 struct SE3GroupAction< ConstraintPrismaticUnaligned<Scalar,Options> >
285 {
typedef Eigen::Matrix<Scalar,6,1,Options> ReturnType; };
287 template<
typename Scalar,
int Options,
typename MotionDerived>
288 struct MotionAlgebraAction< ConstraintPrismaticUnaligned<Scalar,Options>,MotionDerived >
289 {
typedef Eigen::Matrix<Scalar,6,1,Options> ReturnType; };
294 template<
typename _Scalar,
int _Options>
301 typedef _Scalar Scalar;
302 enum { Options = _Options };
309 typedef Eigen::Matrix<Scalar,6,NV,Options> F_t;
312 typedef Eigen::Matrix<Scalar,6,NV,Options> U_t;
313 typedef Eigen::Matrix<Scalar,NV,NV,Options> D_t;
314 typedef Eigen::Matrix<Scalar,6,NV,Options> UD_t;
316 typedef Eigen::Matrix<Scalar,NQ,1,Options> ConfigVector_t;
317 typedef Eigen::Matrix<Scalar,NV,1,Options> TangentVector_t;
320 template<
typename Scalar,
int Options>
324 template<
typename _Scalar,
int _Options>
328 SE3_JOINT_TYPEDEF_TEMPLATE;
344 , S(Motion_t::Vector3::Constant(NAN))
345 , v(Motion_t::Vector3::Constant(NAN),NAN)
346 , U(), Dinv(), UDinv()
349 template<
typename Vector3Like>
354 , U(), Dinv(), UDinv()
359 template<
typename Scalar,
int Options>
363 template<
typename _Scalar,
int _Options>
367 SE3_JOINT_TYPEDEF_TEMPLATE;
373 typedef Motion::Vector3 Vector3;
380 assert(axis.isUnitary() &&
"Translation axis is not unitary");
383 template<
typename Vector3Like>
386 EIGEN_STATIC_ASSERT_VECTOR_ONLY(Vector3Like);
387 assert(axis.isUnitary() &&
"Translation axis is not unitary");
390 JointDataDerived
createData()
const {
return JointDataDerived(axis); }
392 template<
typename ConfigVector>
393 void calc(JointDataDerived & data,
394 const typename Eigen::MatrixBase<ConfigVector> & qs)
const 396 EIGEN_STATIC_ASSERT_VECTOR_ONLY(ConfigVector);
397 typedef typename ConfigVector::Scalar Scalar;
398 const Scalar & q = qs[
idx_q()];
400 data.M.translation().noalias() = axis * q;
403 template<
typename ConfigVector,
typename TangentVector>
404 void calc(JointDataDerived & data,
405 const typename Eigen::MatrixBase<ConfigVector> & qs,
406 const typename Eigen::MatrixBase<TangentVector> & vs)
const 408 EIGEN_STATIC_ASSERT_VECTOR_ONLY(TangentVector);
409 calc(data,qs.derived());
411 typedef typename TangentVector::Scalar S2;
412 const S2 & v = vs[
idx_v()];
416 template<
typename S2,
int O2>
417 void calc_aba(JointDataDerived & data, Eigen::Matrix<S2,6,6,O2> & I,
const bool update_I)
const 419 data.U.noalias() = I.template block<6,3> (0,Inertia::LINEAR) * axis;
420 data.Dinv[0] = Scalar(1)/axis.dot(data.U.template segment <3> (Inertia::LINEAR));
421 data.UDinv.noalias() = data.U * data.Dinv;
424 I -= data.UDinv * data.U.transpose();
430 return sqrt(Eigen::NumTraits<Scalar>::epsilon());
433 static std::string classname() {
return std::string(
"JointModelPrismaticUnalignedTpl"); }
434 std::string
shortname()
const {
return classname(); }
443 #endif // ifndef __se3_joint_prismatic_unaligned_hpp__
JointDataVariant createData(const JointModelVariant &jmodel)
Visit a JointModelVariant through CreateData visitor to create a JointDataVariant.
void calc_aba(const JointModelVariant &jmodel, JointDataVariant &jdata, Inertia::Matrix6 &I, const bool update_I)
Visit a JointDataVariant and the corresponding JointModelVariant through JointCalcAbaVisitor to...
ConstLinearType linear() const
Return the linear part of the force vector.
std::string shortname(const JointModelVariant &jmodel)
Visit a JointModelVariant through JointShortnameVisitor to get the shortname of the derived joint mod...
int idx_q(const JointModelVariant &jmodel)
Visit a JointModelVariant through JointIdxQVisitor to get the index in the full model configuration s...
Eigen::VectorXd finiteDifferenceIncrement(const Model &model)
Computes the finite difference increments for each degree of freedom according to the current joint c...
int idx_v(const JointModelVariant &jmodel)
Visit a JointModelVariant through JointIdxVVisitor to get the index in the full model tangent space c...