-
Notifications
You must be signed in to change notification settings - Fork 246
Writing generic code
Jeremie Deray edited this page Dec 5, 2018
·
2 revisions
All Lie group classes defined in manif
have in common that they inherit from a templated base class.
#include <iostream>
#include <manif/manif.h>
using namespace manif;
template <typename Derived>
void print(const LieGroupBase<Derived>& g)
{
std::cout << "Group degrees of freedom : " << g::DoF << std::endl;
std::cout << "Group underlying representation vector size : " << g::RepSize << std::endl;
std::cout << "Current values : " << g << std::endl;
}
int main()
{
SE2d p_2d;
print(p_2d);
SE3d p_3d;
print(p_3d);
}
#include <iostream>
#include <manif/manif.h>
using namespace manif;
template <typename DerivedA, typename DerivedB>
void ominusSquaredNorm(const LieGroupBase<DerivedA>& g0, const LieGroupBase<DerivedB>& g1)
{
return (g0-g1).coeffs().squaredNorm();
}