2014-12-09 06:58:54 +08:00
|
|
|
/* ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
* GTSAM Copyright 2010, Georgia Tech Research Corporation,
|
|
|
|
|
* Atlanta, Georgia 30332-0415
|
|
|
|
|
* All Rights Reserved
|
|
|
|
|
* Authors: Frank Dellaert, et al. (see THANKS for the full author list)
|
|
|
|
|
|
|
|
|
|
* See LICENSE for the license information
|
|
|
|
|
|
|
|
|
|
* -------------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @file SO3.h
|
2014-12-09 07:52:53 +08:00
|
|
|
* @brief 3*3 matrix representation of SO(3)
|
2014-12-09 06:58:54 +08:00
|
|
|
* @author Frank Dellaert
|
|
|
|
|
* @date December 2014
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include <gtsam/base/Matrix.h>
|
2014-12-22 07:12:08 +08:00
|
|
|
#include <gtsam/base/Lie.h>
|
2014-12-09 06:58:54 +08:00
|
|
|
|
|
|
|
|
#include <cmath>
|
|
|
|
|
|
|
|
|
|
namespace gtsam {
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* True SO(3), i.e., 3*3 matrix subgroup
|
|
|
|
|
* We guarantee (all but first) constructors only generate from sub-manifold.
|
|
|
|
|
* However, round-off errors in repeated composition could move off it...
|
|
|
|
|
*/
|
2015-02-11 03:14:59 +08:00
|
|
|
class GTSAM_EXPORT SO3: public Matrix3, public LieGroup<SO3, 3> {
|
2014-12-09 06:58:54 +08:00
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
|
|
|
|
|
public:
|
2015-02-11 03:14:59 +08:00
|
|
|
enum {
|
|
|
|
|
dimension = 3
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/// @name Constructors
|
|
|
|
|
/// @{
|
2014-12-09 06:58:54 +08:00
|
|
|
|
2014-12-27 20:37:15 +08:00
|
|
|
/// Constructor from AngleAxisd
|
2015-02-11 03:14:59 +08:00
|
|
|
SO3() :
|
|
|
|
|
Matrix3(I_3x3) {
|
2014-12-27 20:37:15 +08:00
|
|
|
}
|
|
|
|
|
|
2014-12-09 06:58:54 +08:00
|
|
|
/// Constructor from Eigen Matrix
|
|
|
|
|
template<typename Derived>
|
|
|
|
|
SO3(const MatrixBase<Derived>& R) :
|
|
|
|
|
Matrix3(R.eval()) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// Constructor from AngleAxisd
|
|
|
|
|
SO3(const Eigen::AngleAxisd& angleAxis) :
|
|
|
|
|
Matrix3(angleAxis) {
|
|
|
|
|
}
|
2014-12-22 09:52:31 +08:00
|
|
|
|
2015-02-11 03:14:59 +08:00
|
|
|
/// Static, named constructor TODO think about relation with above
|
2015-07-06 07:33:10 +08:00
|
|
|
static SO3 AxisAngle(const Vector3& axis, double theta);
|
2015-02-11 03:14:59 +08:00
|
|
|
|
|
|
|
|
/// @}
|
|
|
|
|
/// @name Testable
|
|
|
|
|
/// @{
|
|
|
|
|
|
2014-12-23 21:27:11 +08:00
|
|
|
void print(const std::string& s) const {
|
|
|
|
|
std::cout << s << *this << std::endl;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool equals(const SO3 & R, double tol) const {
|
|
|
|
|
return equal_with_abs_tol(*this, R, tol);
|
|
|
|
|
}
|
|
|
|
|
|
2015-02-11 03:14:59 +08:00
|
|
|
/// @}
|
|
|
|
|
/// @name Group
|
|
|
|
|
/// @{
|
|
|
|
|
|
|
|
|
|
/// identity rotation for group operation
|
|
|
|
|
static SO3 identity() {
|
|
|
|
|
return I_3x3;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// inverse of a rotation = transpose
|
|
|
|
|
SO3 inverse() const {
|
|
|
|
|
return this->Matrix3::inverse();
|
|
|
|
|
}
|
2014-12-27 20:37:15 +08:00
|
|
|
|
2015-02-11 03:14:59 +08:00
|
|
|
/// @}
|
|
|
|
|
/// @name Lie Group
|
|
|
|
|
/// @{
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Exponential map at identity - create a rotation from canonical coordinates
|
2015-07-06 05:03:42 +08:00
|
|
|
* \f$ [R_x,R_y,R_z] \f$ using Rodrigues' formula
|
2015-02-11 03:14:59 +08:00
|
|
|
*/
|
|
|
|
|
static SO3 Expmap(const Vector3& omega, ChartJacobian H = boost::none);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Log map at identity - returns the canonical coordinates
|
|
|
|
|
* \f$ [R_x,R_y,R_z] \f$ of this rotation
|
|
|
|
|
*/
|
2014-12-27 20:37:15 +08:00
|
|
|
static Vector3 Logmap(const SO3& R, ChartJacobian H = boost::none);
|
|
|
|
|
|
2015-02-11 03:14:59 +08:00
|
|
|
/// Derivative of Expmap
|
|
|
|
|
static Matrix3 ExpmapDerivative(const Vector3& omega);
|
|
|
|
|
|
|
|
|
|
/// Derivative of Logmap
|
|
|
|
|
static Matrix3 LogmapDerivative(const Vector3& omega);
|
|
|
|
|
|
|
|
|
|
Matrix3 AdjointMap() const {
|
|
|
|
|
return *this;
|
|
|
|
|
}
|
2014-12-27 20:37:15 +08:00
|
|
|
|
|
|
|
|
// Chart at origin
|
|
|
|
|
struct ChartAtOrigin {
|
2015-02-11 03:14:59 +08:00
|
|
|
static SO3 Retract(const Vector3& omega, ChartJacobian H = boost::none) {
|
|
|
|
|
return Expmap(omega, H);
|
2014-12-27 20:37:15 +08:00
|
|
|
}
|
|
|
|
|
static Vector3 Local(const SO3& R, ChartJacobian H = boost::none) {
|
2015-02-11 03:14:59 +08:00
|
|
|
return Logmap(R, H);
|
2014-12-27 20:37:15 +08:00
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2015-02-11 03:14:59 +08:00
|
|
|
using LieGroup<SO3, 3>::inverse;
|
2014-12-27 20:37:15 +08:00
|
|
|
|
2015-02-11 03:14:59 +08:00
|
|
|
/// @}
|
2014-12-09 06:58:54 +08:00
|
|
|
};
|
|
|
|
|
|
2014-12-18 05:53:56 +08:00
|
|
|
template<>
|
2015-05-26 13:04:04 +08:00
|
|
|
struct traits<SO3> : public internal::LieGroup<SO3> {
|
2015-02-11 03:14:59 +08:00
|
|
|
};
|
2014-12-18 05:53:56 +08:00
|
|
|
|
2015-01-22 02:02:35 +08:00
|
|
|
template<>
|
2015-05-26 13:04:04 +08:00
|
|
|
struct traits<const SO3> : public internal::LieGroup<SO3> {
|
2015-02-11 03:14:59 +08:00
|
|
|
};
|
2014-12-09 06:58:54 +08:00
|
|
|
} // end namespace gtsam
|
|
|
|
|
|