6#ifndef __pinocchio_multibody_joint_spherical_ZYX_hpp__
7#define __pinocchio_multibody_joint_spherical_ZYX_hpp__
9#include "pinocchio/macros.hpp"
10#include "pinocchio/multibody/joint/joint-base.hpp"
11#include "pinocchio/multibody/joint/joint-spherical.hpp"
12#include "pinocchio/multibody/joint-motion-subspace.hpp"
13#include "pinocchio/math/sincos.hpp"
14#include "pinocchio/math/matrix.hpp"
15#include "pinocchio/spatial/inertia.hpp"
16#include "pinocchio/spatial/skew.hpp"
20 template<
typename Scalar,
int Options>
21 struct JointMotionSubspaceSphericalZYXTpl;
23 template<
typename _Scalar,
int _Options>
39 typedef Eigen::Matrix<Scalar, 3, 1, Options> JointForce;
40 typedef Eigen::Matrix<Scalar, 6, 3, Options> DenseBase;
41 typedef Eigen::Matrix<Scalar, 3, 3, Options> ReducedSquaredMatrix;
43 typedef DenseBase MatrixReturnType;
44 typedef const DenseBase ConstMatrixReturnType;
46 typedef ReducedSquaredMatrix StDiagonalMatrixSOperationReturnType;
49 template<
typename _Scalar,
int _Options>
61 typedef Eigen::Matrix<Scalar, 3, 3, Options> Matrix3;
67 template<
typename Matrix3Like>
74 template<
typename Vector3Like>
75 JointMotion __mult__(
const Eigen::MatrixBase<Vector3Like> & v)
const
78 return JointMotion(m_S * v);
81 Matrix3 & operator()()
85 const Matrix3 & operator()()
const
104 template<
typename Derived>
106 Eigen::Transpose<const Matrix3>,
107 Eigen::Block<const typename ForceDense<Derived>::Vector6, 3, 1>>::type
110 return ref.m_S.transpose() *
phi.angular();
116 typename Eigen::Transpose<const Matrix3>,
118 operator*(
const Eigen::MatrixBase<D> &
F)
const
131 DenseBase matrix_impl()
const
143 template<
typename S1,
int O1>
144 Eigen::Matrix<Scalar, 6, 3, Options> se3Action(
const SE3Tpl<S1, O1> & m)
const
152 Eigen::Matrix<Scalar, 6, 3, Options> result;
155 result.template middleRows<3>(ANGULAR).noalias() = m.rotation() * m_S;
159 m.translation(), result.template middleRows<3>(Motion::ANGULAR),
160 result.template middleRows<3>(LINEAR));
165 template<
typename S1,
int O1>
166 Eigen::Matrix<Scalar, 6, 3, Options> se3ActionInverse(
const SE3Tpl<S1, O1> & m)
const
168 Eigen::Matrix<Scalar, 6, 3, Options> result;
171 cross(m.translation(), m_S, result.template middleRows<3>(ANGULAR));
172 result.template middleRows<3>(LINEAR).noalias() =
173 -m.rotation().transpose() * result.template middleRows<3>(ANGULAR);
176 result.template middleRows<3>(ANGULAR).noalias() = m.rotation().transpose() * m_S;
181 template<
typename MotionDerived>
182 DenseBase motionAction(
const MotionDense<MotionDerived> & m)
const
184 const typename MotionDerived::ConstLinearType v = m.linear();
185 const typename MotionDerived::ConstAngularType w = m.angular();
188 cross(v, m_S, res.template middleRows<3>(LINEAR));
189 cross(w, m_S, res.template middleRows<3>(ANGULAR));
194 Matrix3 & angularSubspace()
198 const Matrix3 & angularSubspace()
const
203 bool isEqual(
const JointMotionSubspaceSphericalZYXTpl & other)
const
205 return internal::comparison_eq(m_S, other.m_S);
215 template<
typename Scalar,
int Options>
223 return constraint.matrix().transpose() * constraint.matrix();
229 template<
typename S1,
int O1,
typename S2,
int O2>
230 Eigen::Matrix<S1, 6, 3, O1>
235 Eigen::Matrix<S1, 6, 3, O1> M;
238 (
Y.inertia() -
typename Symmetric3::AlphaSkewSquare(
Y.mass(),
Y.lever())).matrix();
240 return (M * S.angularSubspace()).eval();
245 template<
typename Matrix6Like,
typename S2,
int O2>
246 const typename MatrixMatrixProduct<
247 typename Eigen::internal::remove_const<
248 typename SizeDepType<3>::ColsReturn<Matrix6Like>::ConstType>::type,
249 typename JointMotionSubspaceSphericalZYXTpl<S2, O2>::Matrix3>::type
251 const Eigen::MatrixBase<Matrix6Like> & Y,
const JointMotionSubspaceSphericalZYXTpl<S2, O2> & S)
253 EIGEN_STATIC_ASSERT_MATRIX_SPECIFIC_SIZE(Matrix6Like, 6, 6);
254 return Y.derived().template middleCols<3>(Inertia::ANGULAR) * S.angularSubspace();
257 template<
typename S1,
int O1>
264 typedef Eigen::Matrix<S1, 6, 3, O1> ReturnType;
267 template<
typename S1,
int O1,
typename MotionDerived>
270 typedef Eigen::Matrix<S1, 6, 3, O1> ReturnType;
273 template<
typename Scalar,
int Options>
276 template<
typename _Scalar,
int _Options>
298 typedef Eigen::Matrix<Scalar, 6, NV, Options> U_t;
299 typedef Eigen::Matrix<Scalar, NV, NV, Options> D_t;
300 typedef Eigen::Matrix<Scalar, 6, NV, Options> UD_t;
302 typedef Eigen::Matrix<Scalar, NQ, 1, Options> ConfigVector_t;
303 typedef Eigen::Matrix<Scalar, NV, 1, Options> TangentVector_t;
305 typedef boost::mpl::false_ is_mimicable_t;
307 PINOCCHIO_JOINT_DATA_BASE_ACCESSOR_DEFAULT_RETURN_TYPE
310 template<
typename _Scalar,
int _Options>
317 template<
typename _Scalar,
int _Options>
324 template<
typename _Scalar,
int _Options>
326 :
public JointDataBase<JointDataSphericalZYXTpl<_Scalar, _Options>>
331 PINOCCHIO_JOINT_DATA_BASE_DEFAULT_ACCESSOR
333 ConfigVector_t joint_q;
334 TangentVector_t joint_v;
348 :
joint_q(ConfigVector_t::Zero())
349 ,
joint_v(TangentVector_t::Zero())
350 , S(Constraint_t::Matrix3::Zero())
351 , M(Transformation_t::Identity())
352 , v(Motion_t::Vector3::Zero())
353 , c(Bias_t::Vector3::Zero())
356 , UDinv(UD_t::Zero())
361 static std::string classname()
363 return std::string(
"JointDataSphericalZYX");
365 std::string shortname()
const
373 template<
typename _Scalar,
int _Options>
375 :
public JointModelBase<JointModelSphericalZYXTpl<_Scalar, _Options>>
385 using Base::idx_vExtended;
386 using Base::setIndexes;
388 JointDataDerived createData()
const
390 return JointDataDerived();
393 const std::vector<bool> hasConfigurationLimit()
const
395 return {
true,
true,
true};
398 const std::vector<bool> hasConfigurationLimitInTangent()
const
400 return {
true,
true,
true};
403 template<
typename ConfigVector>
404 void calc(JointDataDerived & data,
const typename Eigen::MatrixBase<ConfigVector> &
qs)
const
418 data.S.angularSubspace() << -
s1, Scalar(0), Scalar(1),
c1 *
s2,
c2, Scalar(0),
c1 *
c2, -
s2,
422 template<
typename TangentVector>
424 calc(JointDataDerived & data,
const Blank,
const typename Eigen::MatrixBase<TangentVector> &
vs)
428 data.v().noalias() = data.S.angularSubspace() * data.joint_v;
439 template<
typename ConfigVector,
typename TangentVector>
441 JointDataDerived & data,
442 const typename Eigen::MatrixBase<ConfigVector> &
qs,
443 const typename Eigen::MatrixBase<TangentVector> &
vs)
const
457 data.S.angularSubspace() << -
s1, Scalar(0), Scalar(1),
c1 *
s2,
c2, Scalar(0),
c1 *
c2, -
s2,
461 data.v().noalias() = data.S.angularSubspace() * data.joint_v;
463#define q_dot data.joint_v
464 data.c()(0) = -
c1 * q_dot(0) * q_dot(1);
466 -
s1 *
s2 * q_dot(0) * q_dot(1) +
c1 *
c2 * q_dot(0) * q_dot(2) -
s2 * q_dot(1) * q_dot(2);
468 -
s1 *
c2 * q_dot(0) * q_dot(1) -
c1 *
s2 * q_dot(0) * q_dot(2) -
c2 * q_dot(1) * q_dot(2);
472 template<
typename VectorLike,
typename Matrix6Like>
474 JointDataDerived & data,
475 const Eigen::MatrixBase<VectorLike> & armature,
476 const Eigen::MatrixBase<Matrix6Like> &
I,
479 data.U.noalias() =
I.template
middleCols<3>(Motion::ANGULAR) * data.S.angularSubspace();
481 data.S.angularSubspace().transpose() * data.U.template
middleRows<3>(Motion::ANGULAR);
482 data.StU.diagonal() += armature;
484 internal::PerformStYSInversion<Scalar>::run(data.StU, data.Dinv);
486 data.UDinv.noalias() = data.U * data.Dinv;
489 PINOCCHIO_EIGEN_CONST_CAST(
Matrix6Like,
I).noalias() -= data.UDinv * data.U.transpose();
492 static std::string classname()
494 return std::string(
"JointModelSphericalZYX");
496 std::string shortname()
const
502 template<
typename NewScalar>
507 res.setIndexes(
id(), idx_q(), idx_v(), idx_vExtended());
515#include <boost/type_traits.hpp>
519 template<
typename Scalar,
int Options>
521 :
public integral_constant<bool, true>
525 template<
typename Scalar,
int Options>
527 :
public integral_constant<bool, true>
531 template<
typename Scalar,
int Options>
533 :
public integral_constant<bool, true>
537 template<
typename Scalar,
int Options>
539 :
public integral_constant<bool, true>
Main pinocchio namespace.
void SINCOS(const S1 &a, S2 *sa, S3 *ca)
Computes sin/cos values of a given input scalar.
JointDataTpl< Scalar, Options, JointCollectionTpl >::TangentVector_t joint_v(const JointDataTpl< Scalar, Options, JointCollectionTpl > &jdata)
Visit a JointDataVariant through JointConfigVisitor to get the joint velocity vector.
void cross(const Eigen::MatrixBase< Vector3 > &v, const Eigen::MatrixBase< Matrix3xIn > &Min, const Eigen::MatrixBase< Matrix3xOut > &Mout)
Applies the cross product onto the columns of M.
void alphaSkew(const Scalar alpha, const Eigen::MatrixBase< Vector3 > &v, const Eigen::MatrixBase< Matrix3 > &M)
Computes the skew representation of a given 3d vector multiplied by a given scalar....
JointDataTpl< Scalar, Options, JointCollectionTpl >::ConfigVector_t joint_q(const JointDataTpl< Scalar, Options, JointCollectionTpl > &jdata)
Visit a JointDataVariant through JointConfigVisitor to get the joint configuration vector.
JointModelSphericalZYXTpl< NewScalar, Options > cast() const
Return type of the ation of a Motion onto an object of type D.
Common traits structure to fully define base classes for CRTP.