19 #ifndef __se3_joint_base_hpp__ 20 #define __se3_joint_base_hpp__ 22 #include "pinocchio/multibody/fwd.hpp" 23 #include "pinocchio/multibody/joint/fwd.hpp" 32 #define SE3_JOINT_TYPEDEF_ARG(prefix) \ 34 typedef prefix traits<JointDerived>::Scalar Scalar; \ 35 typedef prefix traits<JointDerived>::JointDataDerived JointDataDerived; \ 36 typedef prefix traits<JointDerived>::JointModelDerived JointModelDerived; \ 37 typedef prefix traits<JointDerived>::Constraint_t Constraint_t; \ 38 typedef prefix traits<JointDerived>::Transformation_t Transformation_t; \ 39 typedef prefix traits<JointDerived>::Motion_t Motion_t; \ 40 typedef prefix traits<JointDerived>::Bias_t Bias_t; \ 41 typedef prefix traits<JointDerived>::F_t F_t; \ 42 typedef prefix traits<JointDerived>::U_t U_t; \ 43 typedef prefix traits<JointDerived>::D_t D_t; \ 44 typedef prefix traits<JointDerived>::UD_t UD_t; \ 46 NQ = traits<JointDerived>::NQ, \ 47 NV = traits<JointDerived>::NV \ 49 typedef prefix traits<JointDerived>::ConfigVector_t ConfigVector_t; \ 50 typedef prefix traits<JointDerived>::TangentVector_t TangentVector_t 52 #define SE3_JOINT_TYPEDEF SE3_JOINT_TYPEDEF_ARG() 53 #define SE3_JOINT_TYPEDEF_TEMPLATE SE3_JOINT_TYPEDEF_ARG(typename) 55 #elif (__GNUC__ == 4) && (__GNUC_MINOR__ == 4) && (__GNUC_PATCHLEVEL__ == 2) 57 #define SE3_JOINT_TYPEDEF_NOARG() \ 59 typedef traits<JointDerived>::Scalar Scalar; \ 60 typedef traits<JointDerived>::JointDataDerived JointDataDerived; \ 61 typedef traits<JointDerived>::JointModelDerived JointModelDerived; \ 62 typedef traits<JointDerived>::Constraint_t Constraint_t; \ 63 typedef traits<JointDerived>::Transformation_t Transformation_t; \ 64 typedef traits<JointDerived>::Motion_t Motion_t; \ 65 typedef traits<JointDerived>::Bias_t Bias_t; \ 66 typedef traits<JointDerived>::F_t F_t; \ 67 typedef traits<JointDerived>::U_t U_t; \ 68 typedef traits<JointDerived>::D_t D_t; \ 69 typedef traits<JointDerived>::UD_t UD_t; \ 71 NQ = traits<JointDerived>::NQ, \ 72 NV = traits<JointDerived>::NV \ 74 typedef traits<JointDerived>::ConfigVector_t ConfigVector_t; \ 75 typedef traits<JointDerived>::TangentVector_t TangentVector_t 77 #define SE3_JOINT_TYPEDEF_ARG(prefix) \ 79 typedef prefix traits<JointDerived>::Scalar Scalar; \ 80 typedef prefix traits<JointDerived>::JointDataDerived JointDataDerived; \ 81 typedef prefix traits<JointDerived>::JointModelDerived JointModelDerived; \ 82 typedef prefix traits<JointDerived>::Constraint_t Constraint_t; \ 83 typedef prefix traits<JointDerived>::Transformation_t Transformation_t; \ 84 typedef prefix traits<JointDerived>::Motion_t Motion_t; \ 85 typedef prefix traits<JointDerived>::Bias_t Bias_t; \ 86 typedef prefix traits<JointDerived>::F_t F_t; \ 87 typedef prefix traits<JointDerived>::U_t U_t; \ 88 typedef prefix traits<JointDerived>::D_t D_t; \ 89 typedef prefix traits<JointDerived>::UD_t UD_t; \ 91 NQ = traits<JointDerived>::NQ, \ 92 NV = traits<JointDerived>::NV \ 94 typedef prefix traits<JointDerived>::ConfigVector_t ConfigVector_t; \ 95 typedef prefix traits<JointDerived>::TangentVector_t TangentVector_t 97 #define SE3_JOINT_TYPEDEF SE3_JOINT_TYPEDEF_NOARG() 98 #define SE3_JOINT_TYPEDEF_TEMPLATE SE3_JOINT_TYPEDEF_ARG(typename) 102 #define SE3_JOINT_TYPEDEF_ARG() \ 104 typedef typename traits<JointDerived>::Scalar Scalar; \ 105 typedef typename traits<JointDerived>::JointDataDerived JointDataDerived; \ 106 typedef typename traits<JointDerived>::JointModelDerived JointModelDerived; \ 107 typedef typename traits<JointDerived>::Constraint_t Constraint_t; \ 108 typedef typename traits<JointDerived>::Transformation_t Transformation_t; \ 109 typedef typename traits<JointDerived>::Motion_t Motion_t; \ 110 typedef typename traits<JointDerived>::Bias_t Bias_t; \ 111 typedef typename traits<JointDerived>::F_t F_t; \ 112 typedef typename traits<JointDerived>::U_t U_t; \ 113 typedef typename traits<JointDerived>::D_t D_t; \ 114 typedef typename traits<JointDerived>::UD_t UD_t; \ 116 NQ = traits<JointDerived>::NQ, \ 117 NV = traits<JointDerived>::NV \ 119 typedef typename traits<JointDerived>::ConfigVector_t ConfigVector_t; \ 120 typedef typename traits<JointDerived>::TangentVector_t TangentVector_t 122 #define SE3_JOINT_TYPEDEF SE3_JOINT_TYPEDEF_ARG() 123 #define SE3_JOINT_TYPEDEF_TEMPLATE SE3_JOINT_TYPEDEF_ARG() 127 #define SE3_JOINT_USE_INDEXES \ 128 typedef JointModelBase<JointModelDerived> Base; \ 133 template<
typename Derived>
136 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
139 SE3_JOINT_TYPEDEF_TEMPLATE;
141 JointDataDerived& derived() {
return *
static_cast<Derived*
>(
this); }
142 const JointDataDerived& derived()
const {
return *
static_cast<const Derived*
>(
this); }
144 const Constraint_t & S()
const {
return derived().S; }
145 const Transformation_t & M()
const {
return derived().M; }
146 const Motion_t & v()
const {
return derived().v; }
147 const Bias_t & c()
const {
return derived().c; }
148 F_t & F() {
return derived().F; }
150 const U_t & U()
const {
return derived().U; }
151 U_t & U() {
return derived().U; }
152 const D_t & Dinv()
const {
return derived().Dinv; }
153 const UD_t & UDinv()
const {
return derived().UDinv; }
168 typedef typename Mat::template FixedSegmentReturnType<NV>::Type Type;
169 typedef typename Mat::template ConstFixedSegmentReturnType<NV>::Type ConstType;
174 typedef typename Mat::template NColsBlockXpr<NV>::Type Type;
175 typedef typename Mat::template ConstNColsBlockXpr<NV>::Type ConstType;
180 typedef typename Mat::template NRowsBlockXpr<NV>::Type Type;
181 typedef typename Mat::template ConstNRowsBlockXpr<NV>::Type ConstType;
190 typedef typename Mat::SegmentReturnType Type;
191 typedef typename Mat::ConstSegmentReturnType ConstType;
196 typedef typename Mat::ColsBlockXpr Type;
197 typedef typename Mat::ConstColsBlockXpr ConstType;
202 typedef typename Mat::RowsBlockXpr Type;
203 typedef typename Mat::ConstRowsBlockXpr ConstType;
207 template<
typename Derived>
210 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
213 SE3_JOINT_TYPEDEF_TEMPLATE;
216 JointModelDerived& derived() {
return *
static_cast<Derived*
>(
this); }
217 const JointModelDerived& derived()
const {
return *
static_cast<const Derived*
>(
this); }
219 JointDataDerived
createData()
const {
return derived().createData(); }
221 void calc(JointDataDerived& data,
222 const Eigen::VectorXd & qs)
const 223 { derived().calc(data,qs); }
225 void calc(JointDataDerived& data,
226 const Eigen::VectorXd & qs,
227 const Eigen::VectorXd & vs)
const 228 { derived().calc(data,qs,vs); }
230 void calc_aba(JointDataDerived & data,
231 Inertia::Matrix6 & I,
232 const bool update_I =
false)
const 233 { derived().calc_aba(data, I, update_I); }
242 {
return derived().finiteDifferenceIncrement(); }
248 int nv()
const {
return derived().nv_impl(); }
249 int nq()
const {
return derived().nq_impl(); }
251 int nv_impl()
const {
return NV; }
252 int nq_impl()
const {
return NQ; }
254 int idx_q()
const {
return i_q; }
255 int idx_v()
const {
return i_v; }
256 JointIndex
id()
const {
return i_id; }
258 void setIndexes(JointIndex
id,
int q,
int v) { derived().setIndexes_impl(
id, q, v); }
260 void setIndexes_impl(JointIndex
id,
int q,
int v) { i_id =
id, i_q = q; i_v = v; }
262 void disp(std::ostream & os)
const 267 <<
" index: " << i_id << endl
268 <<
" index q: " << i_q << endl
269 <<
" index v: " << i_v << endl
270 <<
" nq: " <<
nq() << endl
271 <<
" nv: " <<
nv() << endl
275 friend std::ostream & operator << (std::ostream & os, const JointModelBase<Derived> & joint)
281 std::string
shortname()
const {
return derived().shortname(); }
282 static std::string classname() {
return Derived::classname(); }
284 template <
class OtherDerived>
287 template <
class OtherDerived>
292 return other.id() ==
id() && other.idx_q() ==
idx_q() && other.idx_v() ==
idx_v();
299 jointConfigSelector(
const Eigen::MatrixBase<D>& a)
const {
return derived().jointConfigSelector_impl(a); }
302 jointConfigSelector_impl(
const Eigen::MatrixBase<D>& a)
const {
return a.template segment<NQ>(i_q); }
306 jointConfigSelector( Eigen::MatrixBase<D>& a)
const {
return derived().jointConfigSelector_impl(a); }
309 jointConfigSelector_impl( Eigen::MatrixBase<D>& a)
const {
return a.template segment<NQ>(i_q); }
315 jointVelocitySelector(
const Eigen::MatrixBase<D>& a)
const {
return derived().jointVelocitySelector_impl(a); }
318 jointVelocitySelector_impl(
const Eigen::MatrixBase<D>& a)
const {
return a.template segment<NV>(i_v); }
322 jointVelocitySelector( Eigen::MatrixBase<D>& a)
const {
return derived().jointVelocitySelector_impl(a); }
325 jointVelocitySelector_impl( Eigen::MatrixBase<D>& a)
const {
return a.template segment<NV>(i_v); }
329 jointCols(
const Eigen::MatrixBase<D>& A)
const {
return derived().jointCols_impl(A); }
332 jointCols_impl(
const Eigen::MatrixBase<D>& A)
const {
return A.template middleCols<NV>(i_v); }
335 jointCols(Eigen::MatrixBase<D>& A)
const {
return derived().jointCols_impl(A); }
338 jointCols_impl(Eigen::MatrixBase<D>& A)
const {
return A.template middleCols<NV>(i_v); }
370 #endif // ifndef __se3_joint_base_hpp__ JointDataVariant createData(const JointModelVariant &jmodel)
Visit a JointModelVariant through CreateData visitor to create a JointDataVariant.
JointModelBase(const JointModelBase &clone)
JointDataBase()
Default constructor: protected.
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...
int nq(const JointModelVariant &jmodel)
Visit a JointModelVariant through JointNqVisitor to get the dimension of the joint configuration spac...
ConfigVector_t::Scalar finiteDifferenceIncrement() const
Return the resolution of the finite differerence increment according to the Scalar type...
void setIndexes(JointModelVariant &jmodel, JointIndex id, int q, int v)
Visit a JointModelVariant through JointSetIndexesVisitor to set the indexes of the joint in the kinem...
std::string shortname(const JointModelVariant &jmodel)
Visit a JointModelVariant through JointShortnameVisitor to get the shortname of the derived joint mod...
int nv(const JointModelVariant &jmodel)
Visit a JointModelVariant through JointNvVisitor to get the dimension of the joint tangent space...
int idx_q(const JointModelVariant &jmodel)
Visit a JointModelVariant through JointIdxQVisitor to get the index in the full model configuration s...
JointIndex id(const JointModelVariant &jmodel)
Visit a JointModelVariant through JointIdVisitor to get the index of the joint in the kinematic chain...
int idx_v(const JointModelVariant &jmodel)
Visit a JointModelVariant through JointIdxVVisitor to get the index in the full model tangent space c...