6 #ifndef __pinocchio_joint_prismatic_unaligned_hpp__ 7 #define __pinocchio_joint_prismatic_unaligned_hpp__ 9 #include "pinocchio/macros.hpp" 10 #include "pinocchio/multibody/joint/joint-base.hpp" 11 #include "pinocchio/multibody/joint/joint-translation.hpp" 12 #include "pinocchio/multibody/constraint.hpp" 13 #include "pinocchio/spatial/inertia.hpp" 23 template<
typename Scalar,
int Options>
29 template<
typename Scalar,
int Options,
typename MotionDerived>
36 template<
typename _Scalar,
int _Options>
39 typedef _Scalar Scalar;
40 enum { Options = _Options };
41 typedef Eigen::Matrix<Scalar,3,1,Options> Vector3;
42 typedef Eigen::Matrix<Scalar,6,1,Options> Vector6;
43 typedef Eigen::Matrix<Scalar,6,6,Options> Matrix6;
44 typedef typename PINOCCHIO_EIGEN_REF_CONST_TYPE(Vector6) ToVectorConstReturnType;
45 typedef typename PINOCCHIO_EIGEN_REF_TYPE(Vector6) ToVectorReturnType;
46 typedef Vector3 AngularType;
47 typedef Vector3 LinearType;
48 typedef const Vector3 ConstAngularType;
49 typedef const Vector3 ConstLinearType;
50 typedef Matrix6 ActionMatrixType;
58 template<
typename _Scalar,
int _Options>
61 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
66 template<
typename Vector3Like,
typename S2>
69 : axis(axis), rate(rate)
70 { EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(Vector3Like,3); }
75 template<
typename Derived>
78 other.linear() += axis * rate;
81 template<
typename Derived>
84 other.linear().noalias() = axis*rate;
85 other.angular().setZero();
88 template<
typename S2,
int O2,
typename D2>
91 v.linear().noalias() = rate * (m.rotation() * axis);
92 v.angular().setZero();
95 template<
typename S2,
int O2>
99 se3Action_impl(m,res);
103 template<
typename S2,
int O2,
typename D2>
107 v.linear().noalias() = rate * (m.rotation().transpose() * axis);
110 v.angular().setZero();
113 template<
typename S2,
int O2>
117 se3ActionInverse_impl(m,res);
121 template<
typename M1,
typename M2>
125 mout.linear().noalias() = v.angular().cross(axis);
126 mout.linear() *= rate;
129 mout.angular().setZero();
132 template<
typename M1>
145 template<
typename Scalar,
int Options,
typename MotionDerived>
146 inline typename MotionDerived::MotionPlain
149 typedef typename MotionDerived::MotionPlain ReturnType;
150 return ReturnType(m1.rate*m1.axis + m2.linear(), m2.angular());
155 template<
typename _Scalar,
int _Options>
158 typedef _Scalar Scalar;
159 enum { Options = _Options };
160 typedef Eigen::Matrix<Scalar,3,1,Options> Vector3;
161 typedef Eigen::Matrix<Scalar,4,1,Options> Vector4;
162 typedef Eigen::Matrix<Scalar,6,1,Options> Vector6;
163 typedef Eigen::Matrix<Scalar,3,3,Options> Matrix3;
164 typedef Eigen::Matrix<Scalar,4,4,Options> Matrix4;
165 typedef Eigen::Matrix<Scalar,6,6,Options> Matrix6;
166 typedef Matrix3 Angular_t;
167 typedef Vector3 Linear_t;
168 typedef const Matrix3 ConstAngular_t;
169 typedef const Vector3 ConstLinear_t;
170 typedef Matrix6 ActionMatrix_t;
171 typedef Eigen::Quaternion<Scalar,Options> Quaternion_t;
181 typedef Eigen::Matrix<Scalar,1,1,Options> JointForce;
182 typedef Eigen::Matrix<Scalar,6,1,Options> DenseBase;
183 typedef DenseBase MatrixReturnType;
184 typedef const DenseBase ConstMatrixReturnType;
187 template<
typename _Scalar,
int _Options>
190 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
192 enum { NV = 1, Options = _Options };
200 template<
typename Vector3Like>
203 { EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(Vector3Like,3); }
205 template<
typename Vector1Like>
206 JointMotion __mult__(
const Eigen::MatrixBase<Vector1Like> & v)
const 208 EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(Vector1Like,1);
209 return JointMotion(axis,v[0]);
212 template<
typename S1,
int O1>
216 res.template head<3>().noalias() = m.rotation()*axis;
217 res.template tail<3>().setZero();
221 int nv_impl()
const {
return NV; }
232 template<
typename Derived>
238 typedef Eigen::Matrix<
242 ReturnType res; res[0] = ref.axis.dot(f.
linear());
249 #if EIGEN_VERSION_AT_LEAST(3,2,90) 250 const Eigen::Product<
251 Eigen::Transpose<const Vector3>,
252 typename Eigen::MatrixBase<const D>::template NRowsBlockXpr<3>::Type
255 const typename Eigen::ProductReturnType<
256 Eigen::Transpose<const Vector3>,
257 typename Eigen::MatrixBase<const D>::template NRowsBlockXpr<3>::Type
260 operator* (
const TransposeConst & tc,
const Eigen::MatrixBase<D> & F)
262 EIGEN_STATIC_ASSERT(D::RowsAtCompileTime==6,THIS_METHOD_IS_ONLY_FOR_MATRICES_OF_A_SPECIFIC_SIZE)
264 return tc.ref.axis.transpose () * F.template topRows<3> ();
277 DenseBase matrix_impl()
const 280 S << axis, Vector3::Zero();
284 template<
typename MotionDerived>
288 res << v.angular().cross(axis), Vector3::Zero();
299 template<
typename MotionDerived,
typename S2,
int O2>
300 inline typename MotionDerived::MotionPlain
304 return m2.motionAction(m1);
308 template<
typename S1,
int O1,
typename S2,
int O2>
309 inline Eigen::Matrix<S1,6,1>
314 const S1 & m = Y.mass();
315 const typename Inertia::Vector3 & c = Y.lever();
317 Eigen::Matrix<S1,6,1> res;
318 res.template head<3>().noalias() = m*cpu.axis;
319 res.template tail<3>() = c.cross(res.template head<3>());
324 template<
typename M6,
typename S2,
int O2>
325 #if EIGEN_VERSION_AT_LEAST(3,2,90) 326 const typename Eigen::Product<
327 Eigen::Block<const M6,6,3>,
329 Eigen::DefaultProduct>
331 const typename Eigen::ProductReturnType<
332 Eigen::Block<const M6,6,3>,
333 const typename ConstraintPrismaticUnaligned<S2,O2>::Vector3
338 EIGEN_STATIC_ASSERT_MATRIX_SPECIFIC_SIZE(M6,6,6);
339 return Y.template block<6,3> (0,Inertia::LINEAR) * cpu.axis;
345 template<
typename Scalar,
int Options>
346 struct SE3GroupAction< ConstraintPrismaticUnaligned<Scalar,Options> >
347 {
typedef Eigen::Matrix<Scalar,6,1,Options> ReturnType; };
349 template<
typename Scalar,
int Options,
typename MotionDerived>
350 struct MotionAlgebraAction< ConstraintPrismaticUnaligned<Scalar,Options>,MotionDerived >
351 {
typedef Eigen::Matrix<Scalar,6,1,Options> ReturnType; };
356 template<
typename _Scalar,
int _Options>
363 typedef _Scalar Scalar;
364 enum { Options = _Options };
371 typedef Eigen::Matrix<Scalar,6,NV,Options> F_t;
374 typedef Eigen::Matrix<Scalar,6,NV,Options> U_t;
375 typedef Eigen::Matrix<Scalar,NV,NV,Options> D_t;
376 typedef Eigen::Matrix<Scalar,6,NV,Options> UD_t;
378 PINOCCHIO_JOINT_DATA_BASE_ACCESSOR_DEFAULT_RETURN_TYPE
380 typedef Eigen::Matrix<Scalar,NQ,1,Options> ConfigVector_t;
381 typedef Eigen::Matrix<Scalar,NV,1,Options> TangentVector_t;
384 template<
typename Scalar,
int Options>
388 template<
typename _Scalar,
int _Options>
390 :
public JointDataBase< JointDataPrismaticUnalignedTpl<_Scalar,_Options> >
392 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
394 PINOCCHIO_JOINT_DATA_TYPEDEF_TEMPLATE;
395 PINOCCHIO_JOINT_DATA_BASE_DEFAULT_ACCESSOR
411 template<
typename Vector3Like>
415 , v(axis,(Scalar)NAN)
416 , U(), Dinv(), UDinv()
419 static std::string classname() {
return std::string(
"JointDataPrismaticUnaligned"); }
420 std::string
shortname()
const {
return classname(); }
424 template<
typename Scalar,
int Options>
429 template<
typename _Scalar,
int _Options>
431 :
public JointModelBase< JointModelPrismaticUnalignedTpl<_Scalar,_Options> >
433 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
435 PINOCCHIO_JOINT_TYPEDEF_TEMPLATE;
441 using Base::setIndexes;
443 typedef Eigen::Matrix<Scalar,3,1,_Options> Vector3;
450 assert(axis.isUnitary() &&
"Translation axis is not unitary");
453 template<
typename Vector3Like>
457 EIGEN_STATIC_ASSERT_VECTOR_ONLY(Vector3Like);
458 assert(axis.isUnitary() &&
"Translation axis is not unitary");
461 JointDataDerived
createData()
const {
return JointDataDerived(axis); }
464 bool isEqual(
const JointModelPrismaticUnalignedTpl & other)
const 466 return Base::isEqual(other) && axis == other.
axis;
469 template<
typename ConfigVector>
470 void calc(JointDataDerived & data,
471 const typename Eigen::MatrixBase<ConfigVector> & qs)
const 473 typedef typename ConfigVector::Scalar Scalar;
474 const Scalar & q = qs[
idx_q()];
476 data.M.translation().noalias() = axis * q;
479 template<
typename ConfigVector,
typename TangentVector>
480 void calc(JointDataDerived & data,
481 const typename Eigen::MatrixBase<ConfigVector> & qs,
482 const typename Eigen::MatrixBase<TangentVector> & vs)
const 484 calc(data,qs.derived());
486 typedef typename TangentVector::Scalar S2;
487 const S2 & v = vs[
idx_v()];
491 template<
typename Matrix6Like>
492 void calc_aba(JointDataDerived & data,
const Eigen::MatrixBase<Matrix6Like> & I,
const bool update_I)
const 494 data.U.noalias() = I.template block<6,3> (0,Inertia::LINEAR) * axis;
495 data.Dinv[0] = Scalar(1)/axis.dot(data.U.template segment <3> (Inertia::LINEAR));
496 data.UDinv.noalias() = data.U * data.Dinv;
499 PINOCCHIO_EIGEN_CONST_CAST(Matrix6Like,I) -= data.UDinv * data.U.transpose();
505 return sqrt(Eigen::NumTraits<Scalar>::epsilon());
508 static std::string classname() {
return std::string(
"JointModelPrismaticUnaligned"); }
509 std::string
shortname()
const {
return classname(); }
512 template<
typename NewScalar>
516 ReturnType res(axis.template cast<NewScalar>());
531 #include <boost/type_traits.hpp> 535 template<
typename Scalar,
int Options>
537 :
public integral_constant<bool,true> {};
539 template<
typename Scalar,
int Options>
541 :
public integral_constant<bool,true> {};
543 template<
typename Scalar,
int Options>
545 :
public integral_constant<bool,true> {};
547 template<
typename Scalar,
int Options>
549 :
public integral_constant<bool,true> {};
553 #endif // ifndef __pinocchio_joint_prismatic_unaligned_hpp__
int idx_q(const JointModelTpl< Scalar, Options, JointCollectionTpl > &jmodel)
Visit a JointModelTpl through JointIdxQVisitor to get the index in the full model configuration space...
int idx_v(const JointModelTpl< Scalar, Options, JointCollectionTpl > &jmodel)
Visit a JointModelTpl through JointIdxVVisitor to get the index in the full model tangent space corre...
JointDataTpl< Scalar, Options, JointCollectionTpl > createData(const JointModelTpl< Scalar, Options, JointCollectionTpl > &jmodel)
Visit a JointModelTpl through CreateData visitor to create a JointDataTpl.
ModelTpl< Scalar, Options, JointCollectionTpl >::TangentVectorType finiteDifferenceIncrement(const ModelTpl< Scalar, Options, JointCollectionTpl > &model)
Computes the finite difference increments for each degree of freedom according to the current joint c...
JointModelPrismaticUnalignedTpl< NewScalar, Options > cast() const
std::string shortname(const JointModelTpl< Scalar, Options, JointCollectionTpl > &jmodel)
Visit a JointModelTpl through JointShortnameVisitor to get the shortname of the derived joint model...
Main pinocchio namespace.
Common traits structure to fully define base classes for CRTP.
ConstLinearType linear() const
Return the linear part of the force vector.
Vector3 axis
3d main axis of the joint.
void calc_aba(const JointModelTpl< Scalar, Options, JointCollectionTpl > &jmodel, JointDataTpl< Scalar, Options, JointCollectionTpl > &jdata, const Eigen::MatrixBase< Matrix6Type > &I, const bool update_I)
Visit a JointModelTpl and the corresponding JointDataTpl through JointCalcAbaVisitor to...