6 #ifndef __pinocchio_joint_free_flyer_hpp__
7 #define __pinocchio_joint_free_flyer_hpp__
9 #include "pinocchio/macros.hpp"
10 #include "pinocchio/spatial/inertia.hpp"
11 #include "pinocchio/spatial/explog.hpp"
12 #include "pinocchio/multibody/joint/joint-base.hpp"
13 #include "pinocchio/multibody/constraint.hpp"
14 #include "pinocchio/math/fwd.hpp"
15 #include "pinocchio/math/quaternion.hpp"
22 template<
typename _Scalar,
int _Options>
25 typedef _Scalar Scalar;
26 enum { Options = _Options };
27 typedef Eigen::Matrix<Scalar,6,6,Options> Matrix6;
33 typedef Eigen::Matrix<Scalar,6,1,Options> JointForce;
34 typedef Eigen::Matrix<Scalar,6,6,Options> DenseBase;
35 typedef typename Matrix6::IdentityReturnType ConstMatrixReturnType;
36 typedef typename Matrix6::IdentityReturnType MatrixReturnType;
40 template<
typename _Scalar,
int _Options>
44 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
49 template<
typename Vector6Like>
50 JointMotion __mult__(
const Eigen::MatrixBase<Vector6Like> & vj)
const
52 EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(Vector6Like,6);
53 return JointMotion(vj);
56 template<
typename S1,
int O1>
57 typename SE3Tpl<S1,O1>::ActionMatrixType
58 se3Action(
const SE3Tpl<S1,O1> & m)
const
60 return m.toActionMatrix();
64 template<
typename S1,
int O1>
65 typename SE3Tpl<S1,O1>::ActionMatrixType
66 se3ActionInverse(
const SE3Tpl<S1,O1> & m)
const
68 return m.toActionMatrixInverse();
71 int nv_impl()
const {
return NV; }
75 template<
typename Derived>
81 template<
typename MatrixDerived>
82 typename PINOCCHIO_EIGEN_REF_CONST_TYPE(MatrixDerived)
83 operator*(
const Eigen::MatrixBase<MatrixDerived> & F)
90 MatrixReturnType matrix_impl()
const {
return DenseBase::Identity(); }
92 template<
typename MotionDerived>
93 typename MotionDerived::ActionMatrixType
94 motionAction(
const MotionBase<MotionDerived> & v)
const
95 {
return v.toActionMatrix(); }
97 bool isEqual(
const ConstraintIdentityTpl &)
const {
return true; }
101 template<
typename Scalar,
int Options,
typename Vector6Like>
102 MotionRef<const Vector6Like>
103 operator*(
const ConstraintIdentityTpl<Scalar,Options> &,
104 const Eigen::MatrixBase<Vector6Like> & v)
106 EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(Vector6Like,6);
108 typedef MotionRef<const Vector6Like> Motion;
109 return Motion(v.derived());
113 template<
typename S1,
int O1,
typename S2,
int O2>
114 inline typename InertiaTpl<S1,O1>::Matrix6
115 operator*(
const InertiaTpl<S1,O1> & Y,
const ConstraintIdentityTpl<S2,O2> &)
121 template<
typename Matrix6Like,
typename S2,
int O2>
122 inline typename PINOCCHIO_EIGEN_REF_CONST_TYPE(Matrix6Like)
123 operator*(
const Eigen::MatrixBase<Matrix6Like> & Y,
const ConstraintIdentityTpl<S2,O2> &)
128 template<
typename S1,
int O1>
132 template<
typename S1,
int O1,
typename MotionDerived>
138 template<
typename _Scalar,
int _Options>
145 typedef _Scalar Scalar;
146 enum { Options = _Options };
155 typedef Eigen::Matrix<Scalar,6,NV,Options> U_t;
156 typedef Eigen::Matrix<Scalar,NV,NV,Options> D_t;
157 typedef Eigen::Matrix<Scalar,6,NV,Options> UD_t;
159 PINOCCHIO_JOINT_DATA_BASE_ACCESSOR_DEFAULT_RETURN_TYPE
161 typedef Eigen::Matrix<Scalar,NQ,1,Options> ConfigVector_t;
162 typedef Eigen::Matrix<Scalar,NV,1,Options> TangentVector_t;
165 template<
typename Scalar,
int Options>
169 template<
typename Scalar,
int Options>
173 template<
typename _Scalar,
int _Options>
176 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
178 PINOCCHIO_JOINT_DATA_TYPEDEF_TEMPLATE(JointDerived);
179 PINOCCHIO_JOINT_DATA_BASE_DEFAULT_ACCESSOR
192 : M(Transformation_t::Identity())
193 , v(Motion_t::Zero())
196 , UDinv(UD_t::Identity())
199 static std::string classname() {
return std::string(
"JointDataFreeFlyer"); }
200 std::string shortname()
const {
return classname(); }
204 PINOCCHIO_JOINT_CAST_TYPE_SPECIALIZATION(JointModelFreeFlyerTpl);
205 template<
typename _Scalar,
int _Options>
206 struct JointModelFreeFlyerTpl
207 :
public JointModelBase< JointModelFreeFlyerTpl<_Scalar,_Options> >
209 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
210 typedef JointFreeFlyerTpl<_Scalar,_Options> JointDerived;
211 PINOCCHIO_JOINT_TYPEDEF_TEMPLATE(JointDerived);
213 typedef JointModelBase<JointModelFreeFlyerTpl> Base;
217 using Base::setIndexes;
219 JointDataDerived createData()
const {
return JointDataDerived(); }
221 const std::vector<bool> hasConfigurationLimit()
const
223 return {
true,
true,
true,
false,
false,
false,
false};
226 const std::vector<bool> hasConfigurationLimitInTangent()
const
228 return {
true,
true,
true,
false,
false,
false};
231 template<
typename ConfigVectorLike>
232 inline void forwardKinematics(Transformation_t & M,
const Eigen::MatrixBase<ConfigVectorLike> & q_joint)
const
234 EIGEN_STATIC_ASSERT_SAME_VECTOR_SIZE(ConfigVector_t,ConfigVectorLike);
235 typedef typename Eigen::Quaternion<
typename ConfigVectorLike::Scalar,PINOCCHIO_EIGEN_PLAIN_TYPE(ConfigVectorLike)::Options> Quaternion;
236 typedef Eigen::Map<const Quaternion> ConstQuaternionMap;
238 ConstQuaternionMap quat(q_joint.template tail<4>().data());
240 assert(math::fabs(
static_cast<Scalar
>(quat.coeffs().squaredNorm()-1)) <= 1e-4);
242 M.rotation(quat.matrix());
243 M.translation(q_joint.template head<3>());
246 template<
typename Vector3Derived,
typename QuaternionDerived>
248 void calc(JointDataDerived & data,
249 const typename Eigen::MatrixBase<Vector3Derived> & trans,
250 const typename Eigen::QuaternionBase<QuaternionDerived> & quat)
const
252 data.M.translation(trans);
253 data.M.rotation(quat.matrix());
256 template<
typename ConfigVector>
258 void calc(JointDataDerived & data,
259 const typename Eigen::PlainObjectBase<ConfigVector> & qs)
const
261 typedef typename Eigen::Quaternion<typename ConfigVector::Scalar,ConfigVector::Options> Quaternion;
262 typedef Eigen::Map<const Quaternion> ConstQuaternionMap;
264 typename ConfigVector::template ConstFixedSegmentReturnType<NQ>::Type q = qs.template segment<NQ>(
idx_q());
265 ConstQuaternionMap quat(q.template tail<4>().data());
267 calc(data,q.template head<3>(),quat);
270 template<
typename ConfigVector>
272 void calc(JointDataDerived & data,
273 const typename Eigen::MatrixBase<ConfigVector> & qs)
const
275 typedef typename Eigen::Quaternion<Scalar,Options> Quaternion;
277 typename ConfigVector::template ConstFixedSegmentReturnType<NQ>::Type q = qs.template segment<NQ>(
idx_q());
278 const Quaternion quat(q.template tail<4>());
280 calc(data,q.template head<3>(),quat);
283 template<
typename ConfigVector,
typename TangentVector>
285 void calc(JointDataDerived & data,
286 const typename Eigen::MatrixBase<ConfigVector> & qs,
287 const typename Eigen::MatrixBase<TangentVector> & vs)
const
289 calc(data,qs.derived());
291 data.v = vs.template segment<NV>(
idx_v());
294 template<
typename Matrix6Like>
295 void calc_aba(JointDataDerived & data,
296 const Eigen::MatrixBase<Matrix6Like> & I,
297 const bool update_I)
const
304 internal::PerformStYSInversion<Scalar>::run(I,data.Dinv);
307 PINOCCHIO_EIGEN_CONST_CAST(Matrix6Like,I).setZero();
310 static std::string classname() {
return std::string(
"JointModelFreeFlyer"); }
311 std::string shortname()
const {
return classname(); }
314 template<
typename NewScalar>
327 #include <boost/type_traits.hpp>
331 template<
typename Scalar,
int Options>
333 :
public integral_constant<bool,true> {};
335 template<
typename Scalar,
int Options>
337 :
public integral_constant<bool,true> {};
339 template<
typename Scalar,
int Options>
341 :
public integral_constant<bool,true> {};
343 template<
typename Scalar,
int Options>
345 :
public integral_constant<bool,true> {};
348 #endif // ifndef __pinocchio_joint_free_flyer_hpp__