11#ifndef SOPHUS_TEST_LOCAL_PARAMETERIZATION_SE3_HPP
22#define SOPHUS_TEST_LOCAL_PARAMETERIZATION_SE3_HPP
33
4- #include < ceres/local_parameterization.h>
54#include < sophus/se3.hpp>
5+ #include " arise_slam_mid360/utils/ceres_compat.h"
66
77namespace Sophus {
88namespace test {
99
10- class LocalParameterizationSE3 : public ceres ::Manifold {
10+ class LocalParameterizationSE3 :
11+ #if ARISE_SLAM_HAS_CERES_MANIFOLD
12+ public ceres::Manifold {
13+ #else
14+ public ceres::LocalParameterization {
15+ #endif
1116 public:
1217 virtual ~LocalParameterizationSE3 () {}
1318
@@ -16,7 +21,7 @@ class LocalParameterizationSE3 : public ceres::Manifold {
1621 // T * exp(x)
1722 //
1823 virtual bool Plus (double const * T_raw, double const * delta_raw,
19- double * T_plus_delta_raw) const {
24+ double * T_plus_delta_raw) const override {
2025 Eigen::Map<SE3d const > const T (T_raw);
2126 Eigen::Map<Vector6d const > const delta (delta_raw);
2227 Eigen::Map<SE3d> T_plus_delta (T_plus_delta_raw);
@@ -28,18 +33,52 @@ class LocalParameterizationSE3 : public ceres::Manifold {
2833 //
2934 // Dx T * exp(x) with x=0
3035 //
36+ #if ARISE_SLAM_HAS_CERES_MANIFOLD
37+ virtual bool PlusJacobian (double const * T_raw,
38+ double * jacobian_raw) const override {
39+ Eigen::Map<SE3d const > T (T_raw);
40+ Eigen::Map<Eigen::Matrix<double , 7 , 6 , Eigen::RowMajor>> jacobian (
41+ jacobian_raw);
42+ jacobian = T.Dx_this_mul_exp_x_at_0 ();
43+ return true ;
44+ }
45+
46+ virtual bool Minus (double const * T_plus_delta_raw, double const * T_raw,
47+ double * delta_raw) const override {
48+ Eigen::Map<SE3d const > const T_plus_delta (T_plus_delta_raw);
49+ Eigen::Map<SE3d const > const T (T_raw);
50+ Eigen::Map<Vector6d> delta (delta_raw);
51+ delta = (T.inverse () * T_plus_delta).log ();
52+ return true ;
53+ }
54+
55+ virtual bool MinusJacobian (double const * T_raw,
56+ double * jacobian_raw) const override {
57+ Eigen::Map<Eigen::Matrix<double , 6 , 7 , Eigen::RowMajor>> jacobian (
58+ jacobian_raw);
59+ jacobian.setZero ();
60+ jacobian.block <3 , 3 >(0 , 4 ).setIdentity ();
61+ jacobian.block <3 , 3 >(3 , 0 ) = 2.0 * Eigen::Matrix3d::Identity ();
62+ return true ;
63+ }
64+
65+ virtual int AmbientSize () const override { return SE3d::num_parameters; }
66+
67+ virtual int TangentSize () const override { return SE3d::DoF; }
68+ #else
3169 virtual bool ComputeJacobian (double const * T_raw,
32- double * jacobian_raw) const {
70+ double * jacobian_raw) const override {
3371 Eigen::Map<SE3d const > T (T_raw);
3472 Eigen::Map<Eigen::Matrix<double , 7 , 6 , Eigen::RowMajor>> jacobian (
3573 jacobian_raw);
3674 jacobian = T.Dx_this_mul_exp_x_at_0 ();
3775 return true ;
3876 }
3977
40- virtual int GlobalSize () const { return SE3d::num_parameters; }
78+ virtual int GlobalSize () const override { return SE3d::num_parameters; }
4179
42- virtual int LocalSize () const { return SE3d::DoF; }
80+ virtual int LocalSize () const override { return SE3d::DoF; }
81+ #endif
4382};
4483} // namespace test
4584} // namespace Sophus
0 commit comments