-
Notifications
You must be signed in to change notification settings - Fork 791
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support Ceres 2.1+ Manifolds in backwards-compatible manner
- Loading branch information
Showing
3 changed files
with
87 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,18 +28,51 @@ | |
// | ||
// Author: [email protected] (Michael Vitus) | ||
|
||
#ifndef CERES_EXAMPLES_POSE_GRAPH_2D_ANGLE_LOCAL_PARAMETERIZATION_H_ | ||
#define CERES_EXAMPLES_POSE_GRAPH_2D_ANGLE_LOCAL_PARAMETERIZATION_H_ | ||
#ifndef CERES_EXAMPLES_POSE_GRAPH_2D_ANGLE_MANIFOLD_H_ | ||
#define CERES_EXAMPLES_POSE_GRAPH_2D_ANGLE_MANIFOLD_H_ | ||
|
||
#include "ceres/local_parameterization.h" | ||
#include "ceres/autodiff_manifold.h" | ||
#include "ceres/manifold.h" | ||
#include "normalize_angle.h" | ||
|
||
namespace ceres { | ||
namespace examples { | ||
|
||
// Defines a local parameterization for updating the angle to be constrained in | ||
// [-pi to pi). | ||
class AngleLocalParameterization { | ||
|
||
#if CERES_VERSION_MAJOR >= 3 || \ | ||
(CERES_VERSION_MAJOR == 2 && CERES_VERSION_MINOR >= 1) | ||
|
||
// Defines a manifold for updating the angle to be constrained in [-pi to pi). | ||
class AngleManifold { | ||
public: | ||
template <typename T> | ||
bool Plus(const T* x_radians, | ||
const T* delta_radians, | ||
T* x_plus_delta_radians) const { | ||
*x_plus_delta_radians = NormalizeAngle(*x_radians + *delta_radians); | ||
return true; | ||
} | ||
|
||
template <typename T> | ||
bool Minus(const T* y_radians, | ||
const T* x_radians, | ||
T* y_minus_x_radians) const { | ||
*y_minus_x_radians = | ||
NormalizeAngle(*y_radians) - NormalizeAngle(*x_radians); | ||
|
||
return true; | ||
} | ||
|
||
static ceres::Manifold* Create() { | ||
return new ceres::AutoDiffManifold<AngleManifold, 1, 1>; | ||
} | ||
}; | ||
|
||
#else | ||
|
||
class AngleManfold { | ||
public: | ||
|
||
template <typename T> | ||
|
@@ -52,12 +85,13 @@ class AngleLocalParameterization { | |
} | ||
|
||
static ceres::LocalParameterization* Create() { | ||
return (new ceres::AutoDiffLocalParameterization<AngleLocalParameterization, | ||
1, 1>); | ||
return (new ceres::AutoDiffLocalParameterization<AngleManfold, 1, 1>); | ||
} | ||
}; | ||
|
||
#endif | ||
|
||
} // namespace examples | ||
} // namespace ceres | ||
|
||
#endif // CERES_EXAMPLES_POSE_GRAPH_2D_ANGLE_LOCAL_PARAMETERIZATION_H_ | ||
#endif // CERES_EXAMPLES_POSE_GRAPH_2D_ANGLE_MANIFOLD_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters