19 #ifndef __se3_joint_prismatic_hpp__ 20 #define __se3_joint_prismatic_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" 26 #include "pinocchio/spatial/spatial-axis.hpp" 27 #include "pinocchio/utils/axis-label.hpp" 34 template<
typename _Scalar,
int _Options,
int _axis>
37 typedef _Scalar Scalar;
38 enum { Options = _Options };
39 typedef Eigen::Matrix<Scalar,3,1,Options> Vector3;
40 typedef Eigen::Matrix<Scalar,6,1,Options> Vector6;
41 typedef Eigen::Matrix<Scalar,6,6,Options> Matrix6;
42 typedef typename EIGEN_REF_CONSTTYPE(Vector6) ToVectorConstReturnType;
43 typedef typename EIGEN_REF_TYPE(Vector6) ToVectorReturnType;
44 typedef Vector3 AngularType;
45 typedef Vector3 LinearType;
46 typedef const Vector3 ConstAngularType;
47 typedef const Vector3 ConstLinearType;
48 typedef Matrix6 ActionMatrixType;
56 template<
typename _Scalar,
int _Options,
int _axis>
66 inline operator MotionPlain()
const {
return Axis() * v; }
68 template<
typename Derived>
72 v_.linear()[_axis] += (OtherScalar) v;
76 template<
typename Scalar,
int Options,
int axis,
typename MotionDerived>
77 typename MotionDerived::MotionPlain
81 typename MotionDerived::MotionPlain res(m2);
88 template<
typename _Scalar,
int _Options,
int axis>
91 typedef _Scalar Scalar;
92 enum { Options = _Options };
93 typedef Eigen::Matrix<Scalar,3,1,Options> Vector3;
94 typedef Eigen::Matrix<Scalar,4,1,Options> Vector4;
95 typedef Eigen::Matrix<Scalar,6,1,Options> Vector6;
96 typedef Eigen::Matrix<Scalar,3,3,Options> Matrix3;
97 typedef Eigen::Matrix<Scalar,4,4,Options> Matrix4;
98 typedef Eigen::Matrix<Scalar,6,6,Options> Matrix6;
99 typedef Matrix3 Angular_t;
100 typedef Vector3 Linear_t;
101 typedef const Matrix3 ConstAngular_t;
102 typedef const Vector3 ConstLinear_t;
103 typedef Matrix6 ActionMatrix_t;
104 typedef Eigen::Quaternion<Scalar,Options> Quaternion_t;
113 typedef Eigen::Matrix<Scalar,1,1,Options> JointMotion;
114 typedef Eigen::Matrix<Scalar,1,1,Options> JointForce;
115 typedef Eigen::Matrix<Scalar,6,1,Options> DenseBase;
116 typedef DenseBase MatrixReturnType;
117 typedef const DenseBase ConstMatrixReturnType;
120 template<
typename _Scalar,
int _Options,
int axis>
124 enum { NV = 1, Options = _Options };
134 assert(v.cols() == 1 && v.rows() == 1);
138 template<
typename S2,
int O2>
143 v.linear() = m.rotation().col(axis);
144 v.angular().setZero();
148 int nv_impl()
const {
return NV; }
155 template<
typename Derived>
158 {
return f.
linear().template segment<1>(axis); }
162 friend typename Eigen::MatrixBase<D>::ConstRowXpr
163 operator*(
const TransposeConst &,
const Eigen::MatrixBase<D> & F )
178 DenseBase matrix_impl()
const 186 template<
typename MotionDerived>
197 template<
typename MotionDerived,
typename S1,
int O1>
198 inline typename MotionDerived::MotionPlain
207 typedef typename MotionDerived::MotionPlain MotionPlain;
208 const typename MotionDerived::ConstAngularType & w = m1.angular();
209 const S1 & vx = m2.v;
210 return MotionPlain(
typename MotionPlain::Vector3(0,w[2]*vx,-w[1]*vx),
211 MotionPlain::Vector3::Zero());
214 template<
typename MotionDerived,
typename S1,
int O1>
215 inline typename MotionDerived::MotionPlain
224 typedef typename MotionDerived::MotionPlain MotionPlain;
225 const typename MotionDerived::ConstAngularType & w = m1.angular();
226 const S1 & vy = m2.v;
227 return MotionPlain(
typename MotionPlain::Vector3(-w[2]*vy,0,w[0]*vy),
228 MotionPlain::Vector3::Zero());
231 template<
typename MotionDerived,
typename S1,
int O1>
232 inline typename MotionDerived::MotionPlain
241 typedef typename MotionDerived::MotionPlain MotionPlain;
242 const typename MotionDerived::ConstAngularType & w = m1.angular();
243 const S1 & vz = m2.v;
244 return MotionPlain(
typename Motion::Vector3(w[1]*vz,-w[0]*vz,0),
245 MotionPlain::Vector3::Zero());
249 template<
typename S1,
int O1,
typename S2,
int O2>
250 inline Eigen::Matrix<S1,6,1,O1>
258 Eigen::Matrix<S1,6,1,O1> res;
259 res << m, S1(0), S1(0), S1(0), m*z, -m*y;
263 template<
typename S1,
int O1,
typename S2,
int O2>
264 inline Eigen::Matrix<S1,6,1,O1>
272 Eigen::Matrix<S1,6,1,O1> res;
273 res << S1(0), m, S1(0), -m*z, S1(0), m*x;
277 template<
typename S1,
int O1,
typename S2,
int O2>
278 inline Eigen::Matrix<S1,6,1,O1>
286 Eigen::Matrix<S1,6,1,O1> res;
287 res << S1(0), S1(0), m, m*y, -m*x, S1(0);
292 template<
typename M6Like,
typename S2,
int O2,
int axis>
293 inline const typename M6Like::ConstColXpr
296 EIGEN_STATIC_ASSERT_MATRIX_SPECIFIC_SIZE(M6Like,6,6);
297 return Y.derived().col(Inertia::LINEAR + axis);
302 template<
typename Scalar,
int Options,
int axis>
303 struct SE3GroupAction< ConstraintPrismatic<Scalar,Options,axis> >
304 {
typedef Eigen::Matrix<Scalar,6,1,Options> ReturnType; };
306 template<
typename Scalar,
int Options,
int axis,
typename MotionDerived>
307 struct MotionAlgebraAction< ConstraintPrismatic<Scalar,Options,axis>, MotionDerived >
308 {
typedef Eigen::Matrix<Scalar,6,1,Options> ReturnType; };
314 template<
typename Scalar,
int Options>
317 template<
typename S1,
typename S2,
int O2>
318 static void cartesianTranslation(
const S1 & shift,
SE3Tpl<S2,O2> & m)
320 m.translation() << (S2)(shift), S2(0), S2(0);
324 template<
typename Scalar,
int Options>
327 template<
typename S1,
typename S2,
int O2>
328 static void cartesianTranslation(
const S1 & shift,
SE3Tpl<S2,O2> & m)
330 m.translation() << S2(0), (S2)(shift), S2(0);
334 template<
typename Scalar,
int Options>
337 template<
typename S1,
typename S2,
int O2>
338 static void cartesianTranslation(
const S1 & shift,
SE3Tpl<S2,O2> & m)
340 m.translation() << S2(0), S2(0), (S2)(shift);
344 template<
typename _Scalar,
int _Options,
int axis>
351 typedef _Scalar Scalar;
352 enum { Options = _Options };
359 typedef Eigen::Matrix<Scalar,6,NV,Options> F_t;
362 typedef Eigen::Matrix<Scalar,6,NV,Options> U_t;
363 typedef Eigen::Matrix<Scalar,NV,NV,Options> D_t;
364 typedef Eigen::Matrix<Scalar,6,NV,Options> UD_t;
366 typedef Eigen::Matrix<Scalar,NQ,1,Options> ConfigVector_t;
367 typedef Eigen::Matrix<Scalar,NV,1,Options> TangentVector_t;
370 template<
typename Scalar,
int Options,
int axis>
374 template<
typename Scalar,
int Options,
int axis>
378 template<
typename _Scalar,
int _Options,
int axis>
382 SE3_JOINT_TYPEDEF_TEMPLATE;
401 template<
typename _Scalar,
int _Options,
int axis>
405 SE3_JOINT_TYPEDEF_TEMPLATE;
412 JointDataDerived
createData()
const {
return JointDataDerived(); }
414 template<
typename ConfigVector>
415 void calc(JointDataDerived & data,
416 const typename Eigen::MatrixBase<ConfigVector> & qs)
const 418 EIGEN_STATIC_ASSERT_VECTOR_ONLY(ConfigVector);
420 typedef typename ConfigVector::Scalar Scalar;
421 const Scalar & q = qs[
idx_q()];
422 JointDerived::cartesianTranslation(q,data.M);
425 template<
typename ConfigVector,
typename TangentVector>
426 void calc(JointDataDerived & data,
427 const typename Eigen::MatrixBase<ConfigVector> & qs,
428 const typename Eigen::MatrixBase<TangentVector> & vs)
const 430 EIGEN_STATIC_ASSERT_VECTOR_ONLY(TangentVector);
431 calc(data,qs.derived());
433 typedef typename TangentVector::Scalar S2;
434 const S2 & v = vs[
idx_v()];
438 template<
typename S2,
int O2>
439 void calc_aba(JointDataDerived & data, Eigen::Matrix<S2,6,6,O2> & I,
const bool update_I)
const 441 data.U = I.col(Inertia::LINEAR + axis);
442 data.Dinv[0] = 1./I(Inertia::LINEAR + axis, Inertia::LINEAR + axis);
443 data.UDinv.noalias() = data.U * data.Dinv[0];
446 I -= data.UDinv * data.U.transpose();
452 return sqrt(Eigen::NumTraits<Scalar>::epsilon());
455 static std::string classname()
457 return std::string(
"JointModelP") + axisLabel<axis>();
459 std::string
shortname()
const {
return classname(); }
477 #endif // ifndef __se3_joint_prismatic_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...