Skip to content
Snippets Groups Projects
Commit 1d50907d authored by Joan Vallvé Navarro's avatar Joan Vallvé Navarro
Browse files

hotfix: pi2pi efficient for jets

parent dcc28f45
No related branches found
No related tags found
2 merge requests!476spdlog version upgrade,!472Merge ProcessorLandmarkExternal
Pipeline #14462 passed
...@@ -27,14 +27,25 @@ ...@@ -27,14 +27,25 @@
#include "core/math/rotations.h" #include "core/math/rotations.h"
namespace wolf{ namespace ceres{
// // efficient implementation of pi2pi for jets (without while)
// template<int N>
// inline ceres::Jet<double, N> pi2pi(const ceres::Jet<double, N>& _angle)
// {
// ceres::Jet<double, N> angle = _angle;
// angle.a = pi2pi(_angle.a);
// return angle;
// }
// }
using std::remainder;
// efficient implementation of pi2pi for jets (without while)
template<int N> template<int N>
inline ceres::Jet<double, N> pi2pi(const ceres::Jet<double, N>& _angle) inline Jet<double, N> remainder(const Jet<double, N>& _x, long double _y)
{ {
ceres::Jet<double, N> angle = _angle; Jet<double, N> res = _x;
angle.a = pi2pi(_angle.a); res.a = remainder(_x.a, _y);
return angle; return res;
} }
} }
\ No newline at end of file
...@@ -41,18 +41,23 @@ namespace wolf ...@@ -41,18 +41,23 @@ namespace wolf
* @param angle * @param angle
* @return formatted angle * @return formatted angle
*/ */
inline long double pi2pi(const long double& _angle) template<typename T>
{ inline T pi2pi(const T& _angle)
return std::remainder(_angle,2*M_PI); {
} return remainder(_angle,2*M_PI);
inline double pi2pi(const double& _angle) }
{ // inline long double pi2pi(const long double& _angle)
return std::remainder(_angle,2*M_PI); // {
} // return std::remainder(_angle,2*M_PI);
inline float pi2pi(const float& _angle) // }
{ // inline double pi2pi(const double& _angle)
return std::remainder(_angle,2*M_PI); // {
} // return std::remainder(_angle,2*M_PI);
// }
// inline float pi2pi(const float& _angle)
// {
// return std::remainder(_angle,2*M_PI);
// }
/** \brief Conversion to radians /** \brief Conversion to radians
* *
......
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