Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add trivial groups Rn #109

Merged
merged 8 commits into from
Feb 20, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ matrix:
- g++-6
script:
- cmake -DENABLE_COVERAGE=ON -DCMAKE_CXX_COMPILER="g++-6" -DBUILD_EXAMPLES=ON -DBUILD_TESTING=ON ..
- make
- travis_wait make
- make test
- cd ..
- bash <(curl -s https://codecov.io/bash)
Expand Down
3 changes: 3 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
-Wno-unused-parameter
-Wno-missing-field-initializers
)
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
target_compile_options(${PROJECT_NAME} INTERFACE /bigobj)
endif()

#############
Expand Down Expand Up @@ -176,6 +178,7 @@ endif(BUILD_EXAMPLES)
# ------------------------------------------------------------------------------

if(ENABLE_COVERAGE)
add_definitions(-DMANIF_COVERAGE_ENABLED)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g ")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O0")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fprofile-arcs")
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
targeted at robotics applications.

At the moment, it provides the groups:
- R(n): Euclidean space with addition.
- SO(2): rotations in the plane.
- SE(2): rigid motion (rotation and translation) in the plane.
- SO(3): rotations in 3D space.
Expand Down
17 changes: 17 additions & 0 deletions include/manif/Rn.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#ifndef _MANIF_RN_H_
#define _MANIF_RN_H_

#include "manif/impl/macro.h"
#include "manif/impl/utils.h"
#include "manif/impl/lie_group_base.h"
#include "manif/impl/tangent_base.h"

#include "manif/impl/rn/Rn_properties.h"
#include "manif/impl/rn/Rn_base.h"
#include "manif/impl/rn/RnTangent_base.h"
#include "manif/impl/rn/Rn.h"
#include "manif/impl/rn/RnTangent.h"
#include "manif/impl/rn/Rn_map.h"
#include "manif/impl/rn/RnTangent_map.h"

#endif // _MANIF_RN_H_
2 changes: 1 addition & 1 deletion include/manif/impl/generator.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ template <typename Derived>
struct GeneratorEvaluator
{
static typename Derived::LieAlg
run(const int)
run(const unsigned int)
{
/// @todo print actual Derived type
static_assert(constexpr_false<Derived>(),
Expand Down
27 changes: 17 additions & 10 deletions include/manif/impl/macro.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,14 @@ raise(Args&&... args)
#define MANIF_DEPRECATED
#endif

// LieGroup - related macros
// Common macros

#define MANIF_MAKE_ALIGNED_OPERATOR_NEW_COND \
EIGEN_MAKE_ALIGNED_OPERATOR_NEW_IF((Eigen::internal::traits<typename Base::DataType>::Alignment>0))
#define MANIF_MAKE_ALIGNED_OPERATOR_NEW_COND_TYPE(X) \
EIGEN_MAKE_ALIGNED_OPERATOR_NEW_IF((Eigen::internal::traits<typename X::DataType>::Alignment>0))

#define MANIF_GROUP_PROPERTIES \
static constexpr int Dim = internal::LieGroupProperties<Type>::Dim; \
static constexpr int DoF = internal::LieGroupProperties<Type>::DoF;
// LieGroup - related macros

#define MANIF_INHERIT_GROUP_AUTO_API \
using Base::setRandom; \
Expand All @@ -104,8 +107,6 @@ raise(Args&&... args)

#define MANIF_INHERIT_GROUP_API \
MANIF_INHERIT_GROUP_AUTO_API \
using Base::transform; \
using Base::rotation; \
using Base::setIdentity; \
using Base::inverse; \
using Base::lift; \
Expand All @@ -120,7 +121,12 @@ raise(Args&&... args)
using Base::operator *=; \
using Base::operator =;

#define MANIF_GROUP_PROPERTIES \
using Base::Dim; \
using Base::DoF;

#define MANIF_GROUP_TYPEDEF \
MANIF_GROUP_PROPERTIES \
using Scalar = typename Base::Scalar; \
using LieGroup = typename Base::LieGroup; \
using Tangent = typename Base::Tangent; \
Expand All @@ -139,10 +145,6 @@ raise(Args&&... args)

// Tangent - related macros

#define MANIF_TANGENT_PROPERTIES \
static constexpr int Dim = internal::LieGroupProperties<Type>::Dim; \
static constexpr int DoF = internal::LieGroupProperties<Type>::DoF;

#define MANIF_INHERIT_TANGENT_API \
using Base::setZero; \
using Base::setRandom; \
Expand All @@ -161,7 +163,12 @@ raise(Args&&... args)
using Base::operator =; \
using Base::operator <<;

#define MANIF_TANGENT_PROPERTIES \
using Base::Dim; \
using Base::DoF;

artivis marked this conversation as resolved.
Show resolved Hide resolved
#define MANIF_TANGENT_TYPEDEF \
MANIF_TANGENT_PROPERTIES \
using Scalar = typename Base::Scalar; \
using LieGroup = typename Base::LieGroup; \
using Tangent = typename Base::Tangent; \
Expand Down
164 changes: 164 additions & 0 deletions include/manif/impl/rn/Rn.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,164 @@
#ifndef _MANIF_MANIF_RN_H_
#define _MANIF_MANIF_RN_H_

#include "manif/impl/rn/Rn_base.h"

namespace manif {

// Forward declare for type traits specialization

template <typename _Scalar, unsigned int N> struct Rn;
template <typename _Scalar, unsigned int N> struct RnTangent;

namespace internal {

//! Traits specialization
template <typename _Scalar, unsigned int _N>
struct traits<Rn<_Scalar, _N>>
{
using Scalar = _Scalar;

using LieGroup = Rn<_Scalar, _N>;
using Tangent = RnTangent<_Scalar, _N>;

using Base = RnBase<Rn<_Scalar, _N>>;

static constexpr int Dim = _N;
static constexpr int DoF = _N;
static constexpr int RepSize = _N;

using DataType = Eigen::Matrix<Scalar, RepSize, 1>;

using Jacobian = Eigen::Matrix<Scalar, DoF, DoF>;
using Transformation = Eigen::Matrix<Scalar, DoF, DoF>;
using Vector = Eigen::Matrix<Scalar, DoF, 1>;
};

} // namespace internal
} // namespace manif

namespace manif {

//
// LieGroup
//

/**
* @brief Represents an element of Rn.
*/
template <typename _Scalar, unsigned int _N>
struct Rn : RnBase<Rn<_Scalar, _N>>
{
private:

static_assert(_N > 0, "N must be greater than 0 !");

using Base = RnBase<Rn<_Scalar, _N>>;
using Type = Rn<_Scalar, _N>;

public:

MANIF_MAKE_ALIGNED_OPERATOR_NEW_COND

MANIF_COMPLETE_GROUP_TYPEDEF
MANIF_INHERIT_GROUP_API

Rn() = default;
~Rn() = default;

// Copy constructor given base
Rn(const Base& o);

template <typename _DerivedOther>
Rn(const RnBase<_DerivedOther>& o);

template <typename _DerivedOther>
Rn(const LieGroupBase<_DerivedOther>& o);

// Copy constructor given Eigen
template <typename _EigenDerived>
Rn(const Eigen::MatrixBase<_EigenDerived>& data);

// LieGroup common API

//! Get a const reference to the underlying DataType.
artivis marked this conversation as resolved.
Show resolved Hide resolved
const DataType& coeffs() const;

// Rn specific API

protected:

friend struct LieGroupBase<Rn<Scalar, _N>>;
DataType& coeffs_nonconst();

DataType data_;
};

template <typename _Scalar> using R1 = Rn<_Scalar, 1>;
template <typename _Scalar> using R2 = Rn<_Scalar, 2>;
template <typename _Scalar> using R3 = Rn<_Scalar, 3>;
template <typename _Scalar> using R4 = Rn<_Scalar, 4>;
template <typename _Scalar> using R5 = Rn<_Scalar, 5>;
template <typename _Scalar> using R6 = Rn<_Scalar, 6>;
template <typename _Scalar> using R7 = Rn<_Scalar, 7>;
template <typename _Scalar> using R8 = Rn<_Scalar, 8>;
template <typename _Scalar> using R9 = Rn<_Scalar, 9>;
artivis marked this conversation as resolved.
Show resolved Hide resolved

MANIF_EXTRA_GROUP_TYPEDEF(R1)
MANIF_EXTRA_GROUP_TYPEDEF(R2)
MANIF_EXTRA_GROUP_TYPEDEF(R3)
MANIF_EXTRA_GROUP_TYPEDEF(R4)
MANIF_EXTRA_GROUP_TYPEDEF(R5)
MANIF_EXTRA_GROUP_TYPEDEF(R6)
MANIF_EXTRA_GROUP_TYPEDEF(R7)
MANIF_EXTRA_GROUP_TYPEDEF(R8)
MANIF_EXTRA_GROUP_TYPEDEF(R9)

template <typename _Scalar, unsigned int _N>
template <typename _EigenDerived>
Rn<_Scalar, _N>::Rn(const Eigen::MatrixBase<_EigenDerived>& data)
: data_(data)
{
//
}

template <typename _Scalar, unsigned int _N>
Rn<_Scalar, _N>::Rn(const Base& o)
: Rn(o.coeffs())
{
//
}

template <typename _Scalar, unsigned int _N>
template <typename _DerivedOther>
Rn<_Scalar, _N>::Rn(const RnBase<_DerivedOther>& o)
: Rn(o.coeffs())
{
//
}

template <typename _Scalar, unsigned int _N>
template <typename _DerivedOther>
Rn<_Scalar, _N>::Rn(const LieGroupBase<_DerivedOther>& o)
: Rn(o.coeffs())
{
//
}

template <typename _Scalar, unsigned int _N>
typename Rn<_Scalar, _N>::DataType&
Rn<_Scalar, _N>::coeffs_nonconst()
{
return data_;
}

template <typename _Scalar, unsigned int _N>
const typename Rn<_Scalar, _N>::DataType&
Rn<_Scalar, _N>::coeffs() const
{
return data_;
}

} /* namespace manif */

#endif /* _MANIF_MANIF_RN_H_ */
Loading