6 #ifndef __pinocchio_spatial_explog_hpp__
7 #define __pinocchio_spatial_explog_hpp__
18 #include <Eigen/Geometry>
33 template<
typename Vector3Like>
42 typedef Eigen::Matrix<Scalar, 3, 3, Vector3LikePlain::Options> Matrix3;
43 const static Scalar eps = Eigen::NumTraits<Scalar>::epsilon();
57 Matrix3
res(alpha_vxvx *
v *
v.transpose());
58 res.coeffRef(0, 1) -= alpha_vx *
v[2];
59 res.coeffRef(1, 0) += alpha_vx *
v[2];
60 res.coeffRef(0, 2) += alpha_vx *
v[1];
61 res.coeffRef(2, 0) -= alpha_vx *
v[1];
62 res.coeffRef(1, 2) -= alpha_vx *
v[0];
63 res.coeffRef(2, 1) += alpha_vx *
v[0];
68 res.diagonal().array() += ct;
80 template<
typename Matrix3Like>
100 template<
typename Matrix3Like>
106 return log3(
R.derived(), theta);
117 template<AssignmentOperatorType op,
typename Vector3Like,
typename Matrix3Like>
118 void Jexp3(
const Eigen::MatrixBase<Vector3Like> &
r,
const Eigen::MatrixBase<Matrix3Like> & Jexp)
126 const Scalar n2 =
r.squaredNorm();
127 const Scalar n = math::sqrt(n2);
129 const Scalar n2_inv = n_inv * n_inv;
139 static_cast<Scalar>(-(1 - cn) * n2_inv));
143 static_cast<Scalar>(n2_inv * (1 -
a)));
148 Jout.diagonal().setConstant(
a);
149 Jout(0, 1) = -
b *
r[2];
150 Jout(1, 0) = -Jout(0, 1);
151 Jout(0, 2) =
b *
r[1];
152 Jout(2, 0) = -Jout(0, 2);
153 Jout(1, 2) = -
b *
r[0];
154 Jout(2, 1) = -Jout(1, 2);
155 Jout.noalias() +=
c *
r *
r.transpose();
158 Jout.diagonal().array() +=
a;
159 Jout(0, 1) += -
b *
r[2];
160 Jout(1, 0) +=
b *
r[2];
161 Jout(0, 2) +=
b *
r[1];
162 Jout(2, 0) += -
b *
r[1];
163 Jout(1, 2) += -
b *
r[0];
164 Jout(2, 1) +=
b *
r[0];
165 Jout.noalias() +=
c *
r *
r.transpose();
168 Jout.diagonal().array() -=
a;
169 Jout(0, 1) -= -
b *
r[2];
170 Jout(1, 0) -=
b *
r[2];
171 Jout(0, 2) -=
b *
r[1];
172 Jout(2, 0) -= -
b *
r[1];
173 Jout(1, 2) -= -
b *
r[0];
174 Jout(2, 1) -=
b *
r[0];
175 Jout.noalias() -=
c *
r *
r.transpose();
178 assert(
false &&
"Wrong Op requesed value");
191 template<
typename Vector3Like,
typename Matrix3Like>
192 void Jexp3(
const Eigen::MatrixBase<Vector3Like> &
r,
const Eigen::MatrixBase<Matrix3Like> & Jexp)
194 Jexp3<SETTO>(
r, Jexp);
239 template<
typename Scalar,
typename Vector3Like,
typename Matrix3Like>
242 const Eigen::MatrixBase<Vector3Like> &
log,
243 const Eigen::MatrixBase<Matrix3Like> & Jlog)
260 template<
typename Matrix3Like1,
typename Matrix3Like2>
262 Jlog3(
const Eigen::MatrixBase<Matrix3Like1> & R,
const Eigen::MatrixBase<Matrix3Like2> & Jlog)
272 template<
typename Scalar,
typename Vector3Like1,
typename Vector3Like2,
typename Matrix3Like>
275 const Eigen::MatrixBase<Vector3Like1> &
log,
276 const Eigen::MatrixBase<Vector3Like2> &
v,
277 const Eigen::MatrixBase<Matrix3Like> & vt_Hlog)
287 SINCOS(theta, &stheta, &ctheta);
289 Scalar denom = .5 / (1 - ctheta),
a = theta * stheta * denom,
290 da_dt = (stheta - theta) * denom,
291 b = (1 -
a) / (theta * theta),
293 db_dt = -(2 / theta - (theta + stheta) * denom) / (theta * theta);
300 Scalar dt_dv_v =
log.dot(dl_dv_v) / theta;
303 vt_Hlog_.noalias() = db_dt * dt_dv_v *
log *
log.transpose();
304 vt_Hlog_.noalias() +=
b * dl_dv_v *
log.transpose();
305 vt_Hlog_.noalias() +=
b *
log * dl_dv_v.transpose();
307 addSkew(.5 * dl_dv_v, vt_Hlog_);
309 vt_Hlog_.diagonal().array() += da_dt * dt_dv_v;
320 template<
typename Matrix3Like1,
typename Vector3Like,
typename Matrix3Like2>
322 const Eigen::MatrixBase<Matrix3Like1> & R,
323 const Eigen::MatrixBase<Vector3Like> &
v,
324 const Eigen::MatrixBase<Matrix3Like2> & vt_Hlog)
343 template<
typename MotionDerived>
358 typename SE3::LinearType & trans =
res.translation();
359 typename SE3::AngularType & rot =
res.rotation();
361 const typename MotionDerived::ConstAngularType &
w = nu.angular();
362 const typename MotionDerived::ConstLinearType &
v = nu.linear();
363 const static Scalar eps = Eigen::NumTraits<Scalar>::epsilon();
365 Scalar alpha_wxv, alpha_v, alpha_w, diagonal_term;
391 trans.noalias() = (alpha_v *
v + (alpha_w *
w.dot(
v)) *
w + alpha_wxv *
w.cross(
v));
394 rot.noalias() = alpha_wxv *
w *
w.transpose();
395 rot.coeffRef(0, 1) -= alpha_v *
w[2];
396 rot.coeffRef(1, 0) += alpha_v *
w[2];
397 rot.coeffRef(0, 2) += alpha_v *
w[1];
398 rot.coeffRef(2, 0) -= alpha_v *
w[1];
399 rot.coeffRef(1, 2) -= alpha_v *
w[0];
400 rot.coeffRef(2, 1) += alpha_v *
w[0];
401 rot.diagonal().array() += diagonal_term;
415 template<
typename Vector6Like>
434 template<
typename Scalar,
int Options>
453 template<
typename Vector3Like,
typename QuaternionLike>
455 const Eigen::QuaternionBase<QuaternionLike> & quat,
const Eigen::MatrixBase<Vector3Like> & vec)
473 template<
typename Matrix4Like>
475 log6(
const Eigen::MatrixBase<Matrix4Like> & M)
495 template<AssignmentOperatorType op,
typename MotionDerived,
typename Matrix6Like>
502 typedef Eigen::Matrix<Scalar, 3, 3, Vector3::Options> Matrix3;
505 const typename MotionDerived::ConstLinearType &
v = nu.
linear();
506 const typename MotionDerived::ConstAngularType &
w = nu.
angular();
518 static_cast<Scalar>(t2inv - st * tinv * inv_2_2ct));
524 -
Scalar(2) * t2inv * t2inv + (
Scalar(1) + st * tinv) * t2inv * inv_2_2ct));
529 Jexp3<SETTO>(
w, Jout.template bottomRightCorner<3, 3>());
530 Jout.template topLeftCorner<3, 3>() = Jout.template bottomRightCorner<3, 3>();
531 const Vector3 p = Jout.template topLeftCorner<3, 3>().transpose() *
v;
534 alphaSkew(.5,
p) + (beta_dot_over_theta * wTp) *
w *
w.transpose()
535 - (
t2 * beta_dot_over_theta +
Scalar(2) * beta) *
p *
w.transpose()
536 + wTp * beta * Matrix3::Identity() + beta *
w *
p.transpose());
537 Jout.template topRightCorner<3, 3>().noalias() = -Jout.template topLeftCorner<3, 3>() *
J;
538 Jout.template bottomLeftCorner<3, 3>().setZero();
545 Jexp3<SETTO>(
w, Jtmp3);
547 Jout.template bottomRightCorner<3, 3>() += Jtmp3;
548 Jout.template topLeftCorner<3, 3>() += Jtmp3;
552 alphaSkew(.5,
p) + (beta_dot_over_theta * wTp) *
w *
w.transpose()
553 - (
t2 * beta_dot_over_theta +
Scalar(2) * beta) *
p *
w.transpose()
554 + wTp * beta * Matrix3::Identity() + beta *
w *
p.transpose());
555 Jout.template topRightCorner<3, 3>().noalias() += -Jtmp3 *
J;
562 Jexp3<SETTO>(
w, Jtmp3);
564 Jout.template bottomRightCorner<3, 3>() -= Jtmp3;
565 Jout.template topLeftCorner<3, 3>() -= Jtmp3;
569 alphaSkew(.5,
p) + (beta_dot_over_theta * wTp) *
w *
w.transpose()
570 - (
t2 * beta_dot_over_theta +
Scalar(2) * beta) *
p *
w.transpose()
571 + wTp * beta * Matrix3::Identity() + beta *
w *
p.transpose());
572 Jout.template topRightCorner<3, 3>().noalias() -= -Jtmp3 *
J;
576 assert(
false &&
"Wrong Op requesed value");
583 template<
typename MotionDerived,
typename Matrix6Like>
586 Jexp6<SETTO>(nu, Jexp);
591 template<
typename MotionDerived>
592 Eigen::Matrix<typename MotionDerived::Scalar, 6, 6, MotionDerived::Options>
600 typedef Eigen::Matrix<Scalar, 6, 6, Options> ReturnType;
667 template<
typename Scalar,
int Options,
typename Matrix6Like>
678 template<
typename Scalar,
int Options>
681 typedef Eigen::Matrix<Scalar, 6, 6, Options> ReturnType;
688 template<
typename Scalar,
int Options>
689 template<
typename OtherScalar>
704 #include "pinocchio/spatial/log.hxx"
706 #endif // #ifndef __pinocchio_spatial_explog_hpp__