6 #ifndef __pinocchio_se3_tpl_hpp__ 7 #define __pinocchio_se3_tpl_hpp__ 9 #include "pinocchio/spatial/fwd.hpp" 10 #include "pinocchio/spatial/se3-base.hpp" 12 #include "pinocchio/math/quaternion.hpp" 13 #include "pinocchio/math/rotation.hpp" 14 #include "pinocchio/spatial/cartesian-axis.hpp" 16 #include <Eigen/Geometry> 20 template<
typename _Scalar,
int _Options>
29 typedef Eigen::Matrix<Scalar,3,1,Options>
Vector3;
30 typedef Eigen::Matrix<Scalar,4,1,Options>
Vector4;
31 typedef Eigen::Matrix<Scalar,6,1,Options>
Vector6;
32 typedef Eigen::Matrix<Scalar,3,3,Options>
Matrix3;
33 typedef Eigen::Matrix<Scalar,4,4,Options>
Matrix4;
34 typedef Eigen::Matrix<Scalar,6,6,Options>
Matrix6;
46 template<typename _Scalar,
int _Options>
49 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
60 using Base::translation;
64 template<
typename QuaternionLike,
typename Vector3Like>
65 SE3Tpl(
const Eigen::QuaternionBase<QuaternionLike> & quat,
66 const Eigen::MatrixBase<Vector3Like> & trans)
67 : rot(quat.
matrix()), trans(trans)
69 EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(Vector3Like,3)
72 template<
typename Matrix3Like,
typename Vector3Like>
73 SE3Tpl(
const Eigen::MatrixBase<Matrix3Like> & R,
74 const Eigen::MatrixBase<Vector3Like> & trans)
75 : rot(R), trans(trans)
77 EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(Vector3Like,3)
78 EIGEN_STATIC_ASSERT_MATRIX_SPECIFIC_SIZE(Matrix3Like,3,3)
81 template<
typename Matrix4Like>
82 explicit SE3Tpl(
const Eigen::MatrixBase<Matrix4Like> & m)
83 : rot(m.template block<3,3>(LINEAR,LINEAR))
84 , trans(m.template block<3,1>(LINEAR,ANGULAR))
86 EIGEN_STATIC_ASSERT_MATRIX_SPECIFIC_SIZE(Matrix4Like,4,4);
90 : rot(AngularType::Identity())
91 , trans(LinearType::Zero())
96 : rot(clone.
rotation()),trans(clone.translation()) {}
112 { rot.
setIdentity (); trans.setZero ();
return *
this;}
117 return SE3Tpl(rot.transpose(), -rot.transpose()*trans);
136 HomogeneousMatrixType
M;
137 M.template block<3,3>(LINEAR,LINEAR) = rot;
138 M.template block<3,1>(LINEAR,ANGULAR) = trans;
139 M.template block<1,3>(ANGULAR,LINEAR).setZero();
147 typedef Eigen::Block<ActionMatrixType,3,3> Block3;
149 M.template block<3,3>(ANGULAR,ANGULAR)
150 = M.template block<3,3>(LINEAR,LINEAR) = rot;
151 M.template block<3,3>(ANGULAR,LINEAR).setZero();
152 Block3 B = M.template block<3,3>(LINEAR,ANGULAR);
154 B.col(0) = trans.cross(rot.col(0));
155 B.col(1) = trans.cross(rot.col(1));
156 B.col(2) = trans.cross(rot.col(2));
162 typedef Eigen::Block<ActionMatrixType,3,3> Block3;
164 M.template block<3,3>(ANGULAR,ANGULAR)
165 = M.template block<3,3>(LINEAR,LINEAR) = rot.transpose();
166 Block3
C = M.template block<3,3>(ANGULAR,LINEAR);
167 Block3 B = M.template block<3,3>(LINEAR,ANGULAR);
169 #define PINOCCHIO_INTERNAL_COMPUTATION(axis_id,v3_in,v3_out,R,res) \ 170 CartesianAxis<axis_id>::cross(v3_in,v3_out); \ 171 res.col(axis_id).noalias() = R.transpose() * v3_out; 177 #undef PINOCCHIO_INTERNAL_COMPUTATION 185 typedef Eigen::Block<ActionMatrixType,3,3> Block3;
187 M.template block<3,3>(ANGULAR,ANGULAR)
188 = M.template block<3,3>(LINEAR,LINEAR) = rot;
189 M.template block<3,3>(LINEAR,ANGULAR).setZero();
190 Block3 B = M.template block<3,3>(ANGULAR,LINEAR);
192 B.col(0) = trans.cross(rot.col(0));
193 B.col(1) = trans.cross(rot.col(1));
194 B.col(2) = trans.cross(rot.col(2));
201 <<
" R =\n" << rot << std::endl
202 <<
" p = " << trans.transpose() << std::endl;
212 return d.se3Action(*
this);
219 return d.se3ActionInverse(*
this);
222 template<
typename EigenDerived>
223 typename EigenDerived::PlainObject
225 {
return (
rotation()*p+translation()).eval(); }
227 template<
typename MapDerived>
229 {
return Vector3(
rotation()*p+translation()); }
231 template<
typename EigenDerived>
232 typename EigenDerived::PlainObject
234 {
return (
rotation().transpose()*(p-translation())).eval(); }
236 template<
typename MapDerived>
238 {
return Vector3(
rotation().transpose()*(p-translation())); }
241 {
return Vector3(
rotation()*p+translation()); }
244 {
return Vector3(
rotation().transpose()*(p-translation())); }
254 rot.transpose()*(m2.
translation()-translation()));}
258 {
return this->act_impl(m2);}
268 const Scalar & prec = Eigen::NumTraits<Scalar>::dummy_precision())
const 274 bool isIdentity(
const Scalar & prec = Eigen::NumTraits<Scalar>::dummy_precision())
const 276 return rotation().isIdentity(prec) && translation().isZero(prec);
287 template<
typename NewScalar>
291 ReturnType
res(rot.template cast<NewScalar>(),
292 trans.template cast<NewScalar>());
300 bool isNormalized(
const Scalar & prec = Eigen::NumTraits<Scalar>::dummy_precision())
const 307 rot = orthogonalProjection(rot);
312 PlainType
res(*
this); res.normalize();
327 template<
typename OtherScalar>
338 template<
typename Scalar,
int Options>
345 template<
typename Scalar,
int Options,
typename NewScalar>
351 if(pinocchio::cast<NewScalar>(Eigen::NumTraits<Scalar>::epsilon()) > Eigen::NumTraits<NewScalar>::epsilon())
360 #endif // ifndef __pinocchio_se3_tpl_hpp__ #define PINOCCHIO_SE3_TYPEDEF_TPL(Derived)
SE3Tpl __mult__(const SE3Tpl< Scalar, O2 > &m2) const
Vector3 actInv_impl(const Vector3 &p) const
void translation_impl(const LinearType &p)
Eigen::Matrix< Scalar, 4, 1, Options > Vector4
SE3Base< SE3Tpl< _Scalar, _Options > > Base
boost::python::object matrix()
bool isIdentity(const Scalar &prec=Eigen::NumTraits< Scalar >::dummy_precision()) const
PINOCCHIO_EIGEN_REF_CONST_TYPE(Matrix6Like) operator*(const Eigen
EigenDerived::PlainObject actOnEigenObject(const Eigen::MatrixBase< EigenDerived > &p) const
SE3Tpl(const Eigen::MatrixBase< Matrix3Like > &R, const Eigen::MatrixBase< Vector3Like > &trans)
ConstLinearRef translation_impl() const
ActionMatrixType toActionMatrixInverse_impl() const
JointCollectionTpl const Eigen::MatrixBase< ConfigVectorType > & q
SE3Tpl act_impl(const SE3Tpl< Scalar, O2 > &m2) const
SE3Tpl(const Eigen::QuaternionBase< QuaternionLike > &quat, const Eigen::MatrixBase< Vector3Like > &trans)
bool isUnitary(const Eigen::MatrixBase< MatrixLike > &mat, const typename MatrixLike::RealScalar &prec=Eigen::NumTraits< typename MatrixLike::Scalar >::dummy_precision())
Check whether the input matrix is Unitary within the given precision.
SE3Tpl & operator=(const SE3Tpl< Scalar, O2 > &other)
ConstAngularRef rotation_impl() const
Eigen::Quaternion< Scalar, Options > Quaternion
bool isNormalized(const Scalar &prec=Eigen::NumTraits< Scalar >::dummy_precision()) const
SE3Tpl actInv_impl(const SE3Tpl< Scalar, O2 > &m2) const
SE3Tpl inverse() const
aXb = bXa.inverse()
traits< SE3Tpl >::Matrix6 Matrix6
HomogeneousMatrixType toHomogeneousMatrix_impl() const
AngularRef rotation_impl()
ActionMatrixType toActionMatrix_impl() const
Vb.toVector() = bXa.toMatrix() * Va.toVector()
PlainType normalized() const
Vector3 actInvOnEigenObject(const Eigen::MapBase< MapDerived > &p) const
SE3Tpl(const Eigen::MatrixBase< Matrix4Like > &m)
void disp_impl(std::ostream &os) const
Vector3 act_impl(const Vector3 &p) const
Eigen::Matrix< Scalar, 4, 4, Options > Matrix4
bool isApprox_impl(const SE3Tpl< Scalar, O2 > &m2, const Scalar &prec=Eigen::NumTraits< Scalar >::dummy_precision()) const
traits< SE3Tpl >::Matrix4 Matrix4
ConstLinearRef translation() const
traits< SE3Tpl >::Vector3 Vector3
void uniformRandom(const Eigen::QuaternionBase< Derived > &q)
Uniformly random quaternion sphere.
traits< SE3Tpl >::Vector4 Vector4
Vector3 actOnEigenObject(const Eigen::MapBase< MapDerived > &p) const
#define PINOCCHIO_EIGEN_REF_TYPE(D)
Main pinocchio namespace.
Base class for rigid transformation.
Eigen::Matrix< Scalar, 6, 1, Options > Vector6
LinearRef translation_impl()
#define PINOCCHIO_INTERNAL_COMPUTATION(axis_id, v3_in, v3_out, R, res)
SE3GroupAction< D >::ReturnType actInv_impl(const D &d) const
by = aXb.actInv(ay)
Common traits structure to fully define base classes for CRTP.
Eigen::Matrix< Scalar, 3, 1, Options > Vector3
Eigen::Matrix< Scalar, 3, 3, Options > Matrix3
SE3Tpl< NewScalar, Options > cast() const
EigenDerived::PlainObject actInvOnEigenObject(const Eigen::MatrixBase< EigenDerived > &p) const
bool isEqual(const SE3Tpl< Scalar, O2 > &m2) const
Matrix4 HomogeneousMatrixType
SE3Tpl(const SE3Tpl< Scalar, O2 > &clone)
traits< SE3Tpl >::Matrix3 Matrix3
Eigen::Matrix< Scalar, 6, 6, Options > Matrix6
ConstAngularRef rotation() const
void rotation_impl(const AngularType &R)
SE3GroupAction< D >::ReturnType act_impl(const D &d) const
— GROUP ACTIONS ON M6, F6 and I6 —
ActionMatrixType toDualActionMatrix_impl() const