6 #ifndef __pinocchio_joint_prismatic_hpp__ 7 #define __pinocchio_joint_prismatic_hpp__ 9 #include "pinocchio/macros.hpp" 10 #include "pinocchio/multibody/joint/joint-base.hpp" 11 #include "pinocchio/multibody/constraint.hpp" 12 #include "pinocchio/spatial/inertia.hpp" 13 #include "pinocchio/spatial/spatial-axis.hpp" 14 #include "pinocchio/utils/axis-label.hpp" 23 template<
typename Scalar,
int Options,
int axis>
29 template<
typename Scalar,
int Options,
int axis,
typename MotionDerived>
36 template<
typename _Scalar,
int _Options,
int _axis>
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,
int _axis>
61 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
64 enum { axis = _axis };
67 typedef typename Axis::CartesianAxis3 CartesianAxis3;
74 template<
typename Derived>
78 other.linear()[_axis] += (OtherScalar) rate;
81 template<
typename MotionDerived>
84 for(Eigen::DenseIndex k = 0; k < 3; ++k)
85 other.linear()[k] = k == axis ? rate : (Scalar)0;
86 other.angular().setZero();
89 template<
typename S2,
int O2,
typename D2>
92 v.angular().setZero();
93 v.linear().noalias() = rate * (m.rotation().col(axis));
96 template<
typename S2,
int O2>
100 se3Action_impl(m,res);
104 template<
typename S2,
int O2,
typename D2>
108 v.linear().noalias() = rate * (m.rotation().transpose().col(axis));
111 v.angular().setZero();
114 template<
typename S2,
int O2>
118 se3ActionInverse_impl(m,res);
122 template<
typename M1,
typename M2>
126 CartesianAxis3::alphaCross(-rate,v.angular(),mout.linear());
129 mout.angular().setZero();
132 template<
typename M1>
144 template<
typename Scalar,
int Options,
int axis,
typename MotionDerived>
145 typename MotionDerived::MotionPlain
149 typename MotionDerived::MotionPlain res(m2);
154 template<
typename MotionDerived,
typename S2,
int O2,
int axis>
156 typename MotionDerived::MotionPlain
159 return m2.motionAction(m1);
164 template<
typename _Scalar,
int _Options,
int _axis>
173 typedef _Scalar Scalar;
175 typedef Eigen::Matrix<Scalar,3,1,Options> Vector3;
176 typedef Eigen::Matrix<Scalar,3,3,Options> Matrix3;
177 typedef typename Matrix3::IdentityReturnType AngularType;
178 typedef AngularType AngularRef;
179 typedef AngularType ConstAngularRef;
180 typedef Vector3 LinearType;
181 typedef const Vector3 LinearRef;
182 typedef const Vector3 ConstLinearRef;
189 template<
typename Scalar,
int Options,
int axis>
190 struct SE3GroupAction< TransformPrismaticTpl<Scalar,Options,axis> >
194 template<
typename _Scalar,
int _Options,
int axis>
197 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
202 typedef typename Axis::CartesianAxis3 CartesianAxis3;
206 : m_displacement(displacement)
209 PlainType plain()
const 211 PlainType res(PlainType::Identity());
212 res.rotation().setIdentity();
213 res.translation()[axis] = m_displacement;
218 operator PlainType()
const {
return plain(); }
220 template<
typename S2,
int O2>
226 res.translation()[axis] += m_displacement;
231 const Scalar & displacement()
const {
return m_displacement; }
232 Scalar & displacement() {
return m_displacement; }
234 ConstLinearRef translation()
const {
return CartesianAxis3()*displacement(); };
235 AngularType rotation()
const {
return AngularType(3,3); }
239 Scalar m_displacement;
244 template<
typename _Scalar,
int _Options,
int axis>
247 typedef _Scalar Scalar;
248 enum { Options = _Options };
249 typedef Eigen::Matrix<Scalar,3,1,Options> Vector3;
250 typedef Eigen::Matrix<Scalar,4,1,Options> Vector4;
251 typedef Eigen::Matrix<Scalar,6,1,Options> Vector6;
252 typedef Eigen::Matrix<Scalar,3,3,Options> Matrix3;
253 typedef Eigen::Matrix<Scalar,4,4,Options> Matrix4;
254 typedef Eigen::Matrix<Scalar,6,6,Options> Matrix6;
255 typedef Matrix3 Angular_t;
256 typedef Vector3 Linear_t;
257 typedef const Matrix3 ConstAngular_t;
258 typedef const Vector3 ConstLinear_t;
259 typedef Matrix6 ActionMatrix_t;
260 typedef Eigen::Quaternion<Scalar,Options> Quaternion_t;
270 typedef Eigen::Matrix<Scalar,1,1,Options> JointForce;
271 typedef Eigen::Matrix<Scalar,6,1,Options> DenseBase;
272 typedef DenseBase MatrixReturnType;
273 typedef const DenseBase ConstMatrixReturnType;
276 template<
typename _Scalar,
int _Options,
int axis>
279 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
281 enum { NV = 1, Options = _Options };
288 template<
typename Vector1Like>
289 JointMotion __mult__(
const Eigen::MatrixBase<Vector1Like> & v)
const 291 EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(Vector1Like,1);
292 assert(v.size() == 1);
293 return JointMotion(v[0]);
296 template<
typename S2,
int O2>
301 v.linear() = m.rotation().col(axis);
302 v.angular().setZero();
306 int nv_impl()
const {
return NV; }
313 template<
typename Derived>
316 {
return f.
linear().template segment<1>(axis); }
320 friend typename Eigen::MatrixBase<D>::ConstRowXpr
321 operator*(
const TransposeConst &,
const Eigen::MatrixBase<D> & F )
336 DenseBase matrix_impl()
const 344 template<
typename MotionDerived>
356 template<
typename S1,
int O1,
typename S2,
int O2>
357 inline Eigen::Matrix<S1,6,1,O1>
365 Eigen::Matrix<S1,6,1,O1> res;
366 res << m, S1(0), S1(0), S1(0), m*z, -m*y;
370 template<
typename S1,
int O1,
typename S2,
int O2>
371 inline Eigen::Matrix<S1,6,1,O1>
379 Eigen::Matrix<S1,6,1,O1> res;
380 res << S1(0), m, S1(0), -m*z, S1(0), m*x;
384 template<
typename S1,
int O1,
typename S2,
int O2>
385 inline Eigen::Matrix<S1,6,1,O1>
393 Eigen::Matrix<S1,6,1,O1> res;
394 res << S1(0), S1(0), m, m*y, -m*x, S1(0);
399 template<
typename M6Like,
typename S2,
int O2,
int axis>
400 inline const typename M6Like::ConstColXpr
403 EIGEN_STATIC_ASSERT_MATRIX_SPECIFIC_SIZE(M6Like,6,6);
404 return Y.derived().col(Inertia::LINEAR + axis);
409 template<
typename Scalar,
int Options,
int axis>
410 struct SE3GroupAction< ConstraintPrismatic<Scalar,Options,axis> >
411 {
typedef Eigen::Matrix<Scalar,6,1,Options> ReturnType; };
413 template<
typename Scalar,
int Options,
int axis,
typename MotionDerived>
414 struct MotionAlgebraAction< ConstraintPrismatic<Scalar,Options,axis>, MotionDerived >
415 {
typedef Eigen::Matrix<Scalar,6,1,Options> ReturnType; };
418 template<
typename _Scalar,
int _Options,
int _axis>
421 typedef _Scalar Scalar;
430 template<
typename _Scalar,
int _Options,
int axis>
437 typedef _Scalar Scalar;
438 enum { Options = _Options };
445 typedef Eigen::Matrix<Scalar,6,NV,Options> F_t;
448 typedef Eigen::Matrix<Scalar,6,NV,Options> U_t;
449 typedef Eigen::Matrix<Scalar,NV,NV,Options> D_t;
450 typedef Eigen::Matrix<Scalar,6,NV,Options> UD_t;
452 PINOCCHIO_JOINT_DATA_BASE_ACCESSOR_DEFAULT_RETURN_TYPE
454 typedef Eigen::Matrix<Scalar,NQ,1,Options> ConfigVector_t;
455 typedef Eigen::Matrix<Scalar,NV,1,Options> TangentVector_t;
458 template<
typename Scalar,
int Options,
int axis>
462 template<
typename Scalar,
int Options,
int axis>
466 template<
typename _Scalar,
int _Options,
int axis>
469 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
471 PINOCCHIO_JOINT_DATA_TYPEDEF_TEMPLATE;
472 PINOCCHIO_JOINT_DATA_BASE_DEFAULT_ACCESSOR
488 static std::string classname() {
return std::string(
"JointDataPrismatic"); }
489 std::string
shortname()
const {
return classname(); }
493 template<
typename NewScalar,
typename Scalar,
int Options,
int axis>
499 template<
typename _Scalar,
int _Options,
int axis>
501 :
public JointModelBase< JointModelPrismaticTpl<_Scalar,_Options,axis> >
503 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
505 PINOCCHIO_JOINT_TYPEDEF_TEMPLATE;
511 using Base::setIndexes;
513 JointDataDerived
createData()
const {
return JointDataDerived(); }
515 template<
typename ConfigVector>
516 void calc(JointDataDerived & data,
517 const typename Eigen::MatrixBase<ConfigVector> & qs)
const 519 typedef typename ConfigVector::Scalar Scalar;
520 const Scalar & q = qs[
idx_q()];
521 data.M.displacement() = q;
524 template<
typename ConfigVector,
typename TangentVector>
525 void calc(JointDataDerived & data,
526 const typename Eigen::MatrixBase<ConfigVector> & qs,
527 const typename Eigen::MatrixBase<TangentVector> & vs)
const 529 calc(data,qs.derived());
531 typedef typename TangentVector::Scalar S2;
532 const S2 & v = vs[
idx_v()];
536 template<
typename Matrix6Like>
537 void calc_aba(JointDataDerived & data,
const Eigen::MatrixBase<Matrix6Like> & I,
const bool update_I)
const 539 data.U = I.col(Inertia::LINEAR + axis);
540 data.Dinv[0] = 1./I(Inertia::LINEAR + axis, Inertia::LINEAR + axis);
541 data.UDinv.noalias() = data.U * data.Dinv[0];
544 PINOCCHIO_EIGEN_CONST_CAST(Matrix6Like,I) -= data.UDinv * data.U.transpose();
550 return sqrt(Eigen::NumTraits<Scalar>::epsilon());
553 static std::string classname()
555 return std::string(
"JointModelP") + axisLabel<axis>();
557 std::string
shortname()
const {
return classname(); }
560 template<
typename NewScalar>
585 #include <boost/type_traits.hpp> 589 template<
typename Scalar,
int Options,
int axis>
591 :
public integral_constant<bool,true> {};
593 template<
typename Scalar,
int Options,
int axis>
595 :
public integral_constant<bool,true> {};
597 template<
typename Scalar,
int Options,
int axis>
599 :
public integral_constant<bool,true> {};
601 template<
typename Scalar,
int Options,
int axis>
603 :
public integral_constant<bool,true> {};
606 #endif // ifndef __pinocchio_joint_prismatic_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...
JointModelPrismaticTpl< NewScalar, Options, axis > 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.
Type of the cast of a class C templated by Scalar and Options, to a new NewScalar type...
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...