Skip to content
Snippets Groups Projects
Commit 2eff3f59 authored by Joan Solà Ortega's avatar Joan Solà Ortega
Browse files

Merge branch 'log_R' into 'master'

Reimplement log_R()

See merge request mobile_robotics/wolf!221
parents d70cf85d 18c9f5bc
No related branches found
No related tags found
1 merge request!221Reimplement log_R()
...@@ -193,6 +193,19 @@ inline Eigen::Matrix<typename Derived::Scalar, 3, 3> exp_R(const Eigen::MatrixBa ...@@ -193,6 +193,19 @@ inline Eigen::Matrix<typename Derived::Scalar, 3, 3> exp_R(const Eigen::MatrixBa
return Eigen::Matrix<T, 3, 3>::Identity() + skew(_v); return Eigen::Matrix<T, 3, 3>::Identity() + skew(_v);
} }
/** \brief rotation matrix to quaternion conversion
*
* @param _R a rotation matrix
* @return the equivalent right-handed unit quaternion
*/
template<typename Derived>
inline Eigen::Quaternion<typename Derived::Scalar> R2q(const Eigen::MatrixBase<Derived>& _R)
{
MatrixSizeCheck<3,3>::check(_R);
return Eigen::Quaternion<typename Derived::Scalar>(_R);
}
/** \brief Rotation matrix logarithmic map /** \brief Rotation matrix logarithmic map
* *
* @param _R a 3D rotation matrix * @param _R a 3D rotation matrix
...@@ -201,12 +214,7 @@ inline Eigen::Matrix<typename Derived::Scalar, 3, 3> exp_R(const Eigen::MatrixBa ...@@ -201,12 +214,7 @@ inline Eigen::Matrix<typename Derived::Scalar, 3, 3> exp_R(const Eigen::MatrixBa
template<typename Derived> template<typename Derived>
inline Eigen::Matrix<typename Derived::Scalar, 3, 1> log_R(const Eigen::MatrixBase<Derived>& _R) inline Eigen::Matrix<typename Derived::Scalar, 3, 1> log_R(const Eigen::MatrixBase<Derived>& _R)
{ {
MatrixSizeCheck<3, 3>::check(_R); return log_q(R2q(_R));
typedef typename Derived::Scalar T;
Eigen::AngleAxis<T> aa = Eigen::AngleAxis<T>(_R);
return aa.axis() * aa.angle();
} }
/** \brief Rotation vector to quaternion conversion /** \brief Rotation vector to quaternion conversion
...@@ -277,19 +285,6 @@ inline Eigen::Matrix<typename Derived::Scalar, 3, 3> q2R(const Eigen::MatrixBase ...@@ -277,19 +285,6 @@ inline Eigen::Matrix<typename Derived::Scalar, 3, 3> q2R(const Eigen::MatrixBase
return q2R( q ); return q2R( q );
} }
/** \brief rotation matrix to quaternion conversion
*
* @param _R a rotation matrix
* @return the equivalent right-handed unit quaternion
*/
template<typename Derived>
inline Eigen::Quaternion<typename Derived::Scalar> R2q(const Eigen::MatrixBase<Derived>& _R)
{
MatrixSizeCheck<3,3>::check(_R);
return Eigen::Quaternion<typename Derived::Scalar>(_R);
}
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
// Jacobians of SO(3) // Jacobians of SO(3)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment