173 struct JointModelCompositeTpl
174 :
public JointModelBase<JointModelCompositeTpl<_Scalar, _Options, JointCollectionTpl>>
176 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
180 PINOCCHIO_JOINT_TYPEDEF_TEMPLATE(JointDerived);
182 typedef JointCollectionTpl<Scalar, Options> JointCollection;
189 typedef PINOCCHIO_ALIGNED_STD_VECTOR(JointModelVariant) JointModelVector;
194 using Base::idx_vExtended;
197 using Base::nvExtended;
198 using Base::setIndexes;
223 jointPlacements.reserve(size);
240 template<
typename Jo
intModel>
243 const SE3 & placement = SE3::Identity(),
244 const std::string &
name =
"joint_1")
245 :
joints(1, (JointModelVariant)jmodel.derived())
246 , jointPlacements(1, placement)
249 , m_nvExtended(jmodel.nvExtended())
251 ,
m_nqs(1, jmodel.nq())
253 ,
m_nvs(1, jmodel.nv())
269 , jointPlacements(other.jointPlacements)
272 , m_nvExtended(other.m_nvExtended)
293 template<
typename Jo
intModel>
296 const SE3 & placement = SE3::Identity(),
297 const std::string &
name =
"")
299 joints.push_back((JointModelVariant)jmodel.derived());
300 jointPlacements.push_back(placement);
304 m_nvExtended += jmodel.nvExtended();
309 std::string final_name =
name;
312 final_name =
"joint_" + std::to_string(
njoints + 1);
319 JointDataDerived createData()
const 321 typename JointDataDerived::JointDataVector jdata(
joints.size());
322 for (
int i = 0; i < (int)
joints.size(); ++i)
324 ::pinocchio::createData<Scalar, Options, JointCollectionTpl>(
joints[(
size_t)i]);
325 return JointDataDerived(jdata,
nq(),
nv());
328 const std::vector<bool> hasConfigurationLimit()
const 330 std::vector<bool> vec;
331 for (
size_t i = 0; i <
joints.size(); ++i)
333 const std::vector<bool> & joint_cf_limit =
joints[i].hasConfigurationLimit();
334 vec.insert(vec.end(), joint_cf_limit.begin(), joint_cf_limit.end());
339 const std::vector<bool> hasConfigurationLimitInTangent()
const 341 std::vector<bool> vec;
342 for (
size_t i = 0; i <
joints.size(); ++i)
344 const std::vector<bool> & joint_cf_limit =
joints[i].hasConfigurationLimitInTangent();
345 vec.insert(vec.end(), joint_cf_limit.begin(), joint_cf_limit.end());
350 template<
typename,
int,
template<
typename S,
int O>
class,
typename>
351 friend struct JointCompositeCalcZeroOrderStep;
353 template<
typename ConfigVectorType>
354 void calc(JointDataDerived & data,
const Eigen::MatrixBase<ConfigVectorType> & qs)
const;
356 template<
typename,
int,
template<
typename S,
int O>
class,
typename,
typename>
357 friend struct JointCompositeCalcFirstOrderStep;
359 template<
typename ConfigVectorType,
typename TangentVectorType>
361 JointDataDerived & data,
362 const Eigen::MatrixBase<ConfigVectorType> & qs,
363 const Eigen::MatrixBase<TangentVectorType> & vs)
const;
365 template<
typename TangentVectorType>
367 JointDataDerived & data,
369 const Eigen::MatrixBase<TangentVectorType> & vs)
const;
371 template<
typename VectorLike,
typename Matrix6Like>
373 JointDataDerived & data,
374 const Eigen::MatrixBase<VectorLike> & armature,
375 const Eigen::MatrixBase<Matrix6Like> & I,
376 const bool update_I)
const 378 data.U.noalias() = I * data.S.matrix();
379 data.StU.noalias() = data.S.matrix().transpose() * data.U;
380 data.StU.diagonal() += armature;
382 internal::PerformStYSInversion<Scalar>::run(data.StU, data.Dinv);
383 data.UDinv.noalias() = data.U * data.Dinv;
386 PINOCCHIO_EIGEN_CONST_CAST(Matrix6Like, I).noalias() -= data.UDinv * data.U.transpose();
397 int nvExtended_impl()
const 407 Base::setIndexes_impl(
id, q, v, vExtended);
411 static std::string classname()
413 return std::string(
"JointModelComposite");
415 std::string shortname()
const 420 JointModelCompositeTpl & operator=(
const JointModelCompositeTpl & other)
425 m_nvExtended = other.m_nvExtended;
433 jointPlacements = other.jointPlacements;
441 bool isEqual(
const JointModelCompositeTpl & other)
const 443 return Base::isEqual(other) && internal::comparison_eq(nq(), other.nq())
444 && internal::comparison_eq(nv(), other.nv())
445 && internal::comparison_eq(nvExtended(), other.nvExtended())
446 && internal::comparison_eq(
m_idx_q, other.m_idx_q)
447 && internal::comparison_eq(
m_idx_v, other.m_idx_v)
449 && internal::comparison_eq(
m_nqs, other.m_nqs)
450 && internal::comparison_eq(
m_nvs, other.m_nvs)
451 && internal::comparison_eq(
m_nvExtendeds, other.m_nvExtendeds)
452 && internal::comparison_eq(
joints, other.joints)
453 && internal::comparison_eq(jointPlacements, other.jointPlacements)
454 && internal::comparison_eq(
njoints, other.njoints)
455 && internal::comparison_eq(
jointNames, other.jointNames);
459 template<
typename NewScalar>
460 JointModelCompositeTpl<NewScalar, Options, JointCollectionTpl>
cast()
const 462 typedef JointModelCompositeTpl<NewScalar, Options, JointCollectionTpl>
ReturnType;
464 res.setIndexes(
id(), idx_q(), idx_v(), idx_vExtended());
467 res.m_nvExtended = m_nvExtended;
477 res.joints.resize(
joints.size());
478 res.jointPlacements.resize(jointPlacements.size());
479 for (
size_t k = 0; k < jointPlacements.size(); ++k)
482 res.jointPlacements[k] = jointPlacements[k].template
cast<NewScalar>();
488 JointIndex getJointId(
const std::string & joint_name)
const 493 PINOCCHIO_THROW_PRETTY(std::invalid_argument,
"JointComposite - joint_name not found");
495 return JointIndex(std::distance(
jointNames.begin(), it));
506 JointMappedConfigSelector(
const Eigen::MatrixBase<D> & a)
const 508 return a.segment(Base::i_q, nq());
512 JointMappedConfigSelector(Eigen::MatrixBase<D> & a)
const 514 return a.segment(Base::i_q,
nq());
518 typename SizeDepType<NQ>::template SegmentReturn<D>::ConstType
519 jointConfigSelector(
const Eigen::MatrixBase<D> & a)
const 521 return a.segment(Base::i_q, nq());
524 typename SizeDepType<NQ>::template SegmentReturn<D>::Type
525 jointConfigSelector(Eigen::MatrixBase<D> & a)
const 527 return a.segment(Base::i_q, nq());
531 typename SizeDepType<NV>::template SegmentReturn<D>::ConstType
532 JointMappedVelocitySelector(
const Eigen::MatrixBase<D> & a)
const 534 return a.segment(Base::i_v, nv());
537 typename SizeDepType<NV>::template SegmentReturn<D>::Type
538 JointMappedVelocitySelector(Eigen::MatrixBase<D> & a)
const 540 return a.segment(Base::i_v, nv());
544 typename SizeDepType<NV>::template SegmentReturn<D>::ConstType
545 jointVelocitySelector(
const Eigen::MatrixBase<D> & a)
const 547 return a.segment(Base::i_v, nv());
550 typename SizeDepType<NV>::template SegmentReturn<D>::Type
551 jointVelocitySelector(Eigen::MatrixBase<D> & a)
const 553 return a.segment(Base::i_v, nv());
557 typename SizeDepType<NV>::template ColsReturn<D>::ConstType
558 jointCols(
const Eigen::MatrixBase<D> & A)
const 560 return A.middleCols(Base::i_v, nv());
563 typename SizeDepType<NV>::template ColsReturn<D>::ConstType
564 jointExtendedModelCols(
const Eigen::MatrixBase<D> & A)
const 566 return A.middleCols(Base::i_vExtended, nvExtended());
569 typename SizeDepType<NV>::template ColsReturn<D>::Type jointCols(Eigen::MatrixBase<D> & A)
const 571 return A.middleCols(Base::i_v, nv());
574 typename SizeDepType<NV>::template ColsReturn<D>::Type
575 jointExtendedModelCols(Eigen::MatrixBase<D> & A)
const 577 return A.middleCols(Base::i_vExtended, nvExtended());
581 typename SizeDepType<Eigen::Dynamic>::template SegmentReturn<D>::ConstType
582 jointConfigSelector_impl(
const Eigen::MatrixBase<D> & a)
const 584 return a.segment(Base::i_q, nq());
587 typename SizeDepType<Eigen::Dynamic>::template SegmentReturn<D>::Type
588 jointConfigSelector_impl(Eigen::MatrixBase<D> & a)
const 590 return a.segment(Base::i_q, nq());
594 typename SizeDepType<Eigen::Dynamic>::template SegmentReturn<D>::ConstType
595 JointMappedConfigSelector_impl(
const Eigen::MatrixBase<D> & a)
const 597 return a.segment(Base::i_q, nq());
600 typename SizeDepType<Eigen::Dynamic>::template SegmentReturn<D>::Type
601 JointMappedConfigSelector_impl(Eigen::MatrixBase<D> & a)
const 603 return a.segment(Base::i_q, nq());
607 typename SizeDepType<Eigen::Dynamic>::template SegmentReturn<D>::ConstType
608 JointMappedVelocitySelector_impl(
const Eigen::MatrixBase<D> & a)
const 610 return a.segment(Base::i_v, nv());
613 typename SizeDepType<Eigen::Dynamic>::template SegmentReturn<D>::Type
614 JointMappedVelocitySelector_impl(Eigen::MatrixBase<D> & a)
const 616 return a.segment(Base::i_v, nv());
620 typename SizeDepType<Eigen::Dynamic>::template SegmentReturn<D>::ConstType
621 jointVelocitySelector_impl(
const Eigen::MatrixBase<D> & a)
const 623 return a.segment(Base::i_v, nv());
626 typename SizeDepType<Eigen::Dynamic>::template SegmentReturn<D>::Type
627 jointVelocitySelector_impl(Eigen::MatrixBase<D> & a)
const 629 return a.segment(Base::i_v, nv());
633 typename SizeDepType<Eigen::Dynamic>::template ColsReturn<D>::ConstType
634 jointCols_impl(
const Eigen::MatrixBase<D> & A)
const 636 return A.middleCols(Base::i_v, nv());
639 typename SizeDepType<Eigen::Dynamic>::template ColsReturn<D>::ConstType
640 jointExtendedModelCols_impl(
const Eigen::MatrixBase<D> & A)
const 642 return A.middleCols(Base::i_vExtended, nvExtended());
645 typename SizeDepType<Eigen::Dynamic>::template ColsReturn<D>::Type
646 jointCols_impl(Eigen::MatrixBase<D> & A)
const 648 return A.middleCols(Base::i_v, nv());
651 typename SizeDepType<Eigen::Dynamic>::template ColsReturn<D>::Type
652 jointExtendedModelCols_impl(Eigen::MatrixBase<D> & A)
const 654 return A.middleCols(Base::i_vExtended, nvExtended());
657 void disp(std::ostream & os)
const 659 typedef typename JointModelCompositeTpl<Scalar, Options, JointCollectionTpl>::JointModelVector
662 os <<
"JointModelComposite containing following models:\n";
663 for (
typename JointModelVector::const_iterator it =
joints.begin(); it !=
joints.end(); ++it)
664 os <<
" " << it->shortname() << std::endl;
668 friend struct Serialize<JointModelCompositeTpl>;
670 template<
typename,
int,
template<
typename,
int>
class>
671 friend struct JointModelCompositeTpl;
677 int idx_q = this->idx_q();
678 int idx_v = this->idx_v();
679 int idx_vExtended = this->idx_vExtended();
688 for (
size_t i = 0; i <
joints.size(); ++i)
690 JointModelVariant & joint =
joints[i];