Problem log during XTDrone and PX4 study

Problem record during XTDrone and PX4 learning (1)

Written By PiscesAlpaca

Foreword:

If there is a problem, you can go to the official website http://ceres-solver.org/index... Looking at the documentation, it is difficult for search engines to find the corresponding problem. (But I wrote the solutions to these problems, maybe I can find them later hh

1. Visual SLAM articles

URL: Visual SLAM · Yuque

ORBSLAM2 compilation

Compile dependencies see ORBSLAM2 compilation dependencies

Note that ORBSLAM2 is slightly modified on the basis of the original version. Although it supports ROS, it is not a standard ROS architecture, so it cannot be compiled with catkin build.

cp -r ~/XTDrone/sensing/slam/vslam/ORB_SLAM2/ ~/catkin_ws/src/
mkdir ~/catkin_ws/scripts/
cp ~/catkin_ws/src/ORB_SLAM2/xtdrone* ~/catkin_ws/scripts/
cd ~/catkin_ws/src/ORB_SLAM2
chmod +x build.sh
./build.sh
export ROS_PACKAGE_PATH=$ROS_PACKAGE_PATH:~/catkin_ws/src/ORB_SLAM2/Examples/ROS #Put this sentence in ~/.bashrc, it will be more convenient to use later
chmod +x build_ros.sh
./build_ros.sh

Problem: When doing ./build.sh, I encountered make[2]: *** No rule to make target '../Thirdparty/DBoW2/lib/libDBoW2.so', needed by '../lib/libORB_SLAM3 .so'. Stop.

Solution: Manually cd into the directory ORB_SLAM3/Thirdparty/DBoW2/build, run cmake .. and build -j4 in turn, then you can find that the libDBoW2.so file is generated in the lib directory, and then follow the tutorial to run ./build.sh 100% complete compilation.

2. 3D Laser SLAM

Problem: encountered `/home/pisces/catkin_ws/src/A-LOAM/src/laserOdometry.cpp:286:29: error: expected type-specifier when running catkin_make command
286 | new ceres::EigenQuaternionParameterization();

  |                             ^~~~~                                   `

Solution:

Official documentation shows

EigenQuaternionParameterization is deprecated. It will be
removed in version 2.2.0 of Ceres Solver. Please use EigenQuaternionManifold instead.

Prove that EigenQuaternionParameterization is obsolete and needs to be replaced with EigenQuaternionManifold, ie:

ceres::LocalParameterization *q_parameterization = new ceres::EigenQuaternionParameterization();

Replace with: ``

ceres::LocalParameterization *q_parameterization = new ceres::EigenQuaternionManifold();

3. Visual Inertial Odometer

question:

`/home/pisces/catkin_ws/src/VINS-Fusion/camera_models/src/calib/CameraCalibration.cc:508:17: error: cannot convert 'camodocal::EigenQuaternionParameterization' to 'ceres::LocalParameterization' in initialization

         new EigenQuaternionParameterization;
             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~`

Workaround: Change ceres::LocalParameterization* to ceres::Manifold*

which is

        ceres::Manifold* quaternionParameterization =
            new EigenQuaternionParameterization;

question:

`/home/pisces/catkin_ws/src/VINS-Fusion/camera_models/src/calib/CameraCalibration.cc:510:17: error: 'class ceres::Problem' has no member named 'SetParameterization'; did you mean 'SetParameterLowerBound'?

     problem.SetParameterization(transformVec.at(i).rotationData(),
             ^~~~~~~~~~~~~~~~~~~
             SetParameterLowerBound`

Solution:

This method is deprecated and will be removed in Ceres Solver version 2.2.0. Please move to using the SetManifold instead.

which is

        problem.SetManifold(transformVec.at(i).rotationData(),
                                    quaternionParameterization);

question:

`/home/pisces/catkin_ws/src/VINS-Fusion/global_fusion/src/globalOpt.cpp:109:72: error: expected type-specifier

         ceres::LocalParameterization* local_parameterization = new ceres::QuaternionParameterization();
                                                                    ^~~~~`

Solution:

QuaternionParameterization is deprecated. It will be removed in version 2.2.0 of Ceres Solver. Please use QuaternionManifold instead.

which is

            ceres::Manifold* local_parameterization = new ceres::QuaternionManifold();

question:

`/home/pisces/catkin_ws/src/VINS-Fusion/camera_models/src/calib/CameraCalibration.cc:508:17: error: invalid new-expression of abstract class type 'camodocal::EigenQuaternionParameterization'

         new EigenQuaternionParameterization;
             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~`

Solution: The essence is that a new pure virtual function appears in the newly inherited Manifold class, which only needs to be implemented in the EigenQuaternionParameterization class

Add under EigenQuaternionParameterization class public:

    virtual int AmbientSize() const {return 7;}
    virtual int TangentSize() const {return 1;}
    virtual bool PlusJacobian(const double* x, double* jacobian) const {return 1;}
    virtual bool Minus(const double* y,
                       const double* x,
                       double* y_minus_x) const {return 1;}
    virtual bool MinusJacobian(const double* x, double* jacobian) const {return 1;}

which is

class EigenQuaternionParameterization : public ceres::Manifold
{
public:
    virtual ~EigenQuaternionParameterization() {}
    virtual bool Plus(const double* x,
                      const double* delta,
                      double* x_plus_delta) const;
    virtual bool ComputeJacobian(const double* x,
                                 double* jacobian) const;
    virtual int GlobalSize() const { return 4; }
    virtual int LocalSize() const { return 3; }

    //edit by PiscesAlpaca
    virtual int AmbientSize() const {return 1;}
    virtual int TangentSize() const {return 1;}
    virtual bool PlusJacobian(const double* x, double* jacobian) const {return 1;}
    virtual bool Minus(const double* y,
                       const double* x,
                       double* y_minus_x) const {return 1;}
    virtual bool MinusJacobian(const double* x, double* jacobian) const {return 1;}

private:
    template<typename T>
    void EigenQuaternionProduct(const T z[4], const T w[4], T zw[4]) const;
};

question:

`/home/pisces/catkin_ws/src/VINS-Fusion/loop_fusion/src/pose_graph.h:134:24: error: 'AutoDiffLocalParameterization' in namespace 'ceres' does not name a template type

 return (new ceres::AutoDiffLocalParameterization<AngleLocalParameterization,
                    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~`

Solution:

AutoDiffParameterization is deprecated. It will be removed in version 2.2.0 of Ceres Solver. Please use AutoDiffManifold instead.

which is

  static ceres::Manifold* Create() {
    return (new ceres::AutoDiffManifold <AngleLocalParameterization,
                                                     1, 1>);
  }

Note: If the compilation prompts that the Plus and Minus functions are missing after making changes, you can add them to the pose_graph.h file

class AngleLocalParameterization {
 public:

  template <typename T>
  bool operator()(const T* theta_radians, const T* delta_theta_radians,
                  T* theta_radians_plus_delta) const {
    *theta_radians_plus_delta =
        NormalizeAngle(*theta_radians + *delta_theta_radians);

    return true;
  }

  //edit by pisces
    bool Plus(const double* x,
              const double* delta,
              double* x_plus_delta) {
        return true;
    }
    //edit by pisces
    bool Minus(const double* y,
               const double* x,
               double* y_minus_x) {
        return true;
    }
    //edit by pisces
    template <typename T>
    bool Plus(const T* x,
              const T* delta,
              T* x_plus_delta) const{
        return true;
    }
    //edit by pisces
    template <typename T>
    bool Minus(const T* y,
               const T* x,
               T* y_minus_x) const{
        return true;
    }

    static ceres::Manifold* Create() {
    return (new ceres::AutoDiffManifold <AngleLocalParameterization,
                                                     1, 1>);
  }
};

//edit by pisces is an added function

question:

`/home/pisces/catkin_ws/src/VINS-Fusion/vins_estimator/src/estimator/../factor/pose_local_parameterization.h:16:49: error: invalid use of incomplete type 'class ceres::LocalParameterization'
class PoseLocalParameterization : public ceres::LocalParameterization

                                             ^~~~~~~~~~~~~~~~~~~~~`

Workaround: Change ceres::LocalParameterization* to ceres::Manifold*

Same as question 1 of this section

question:

`/home/pisces/catkin_ws/src/VINS-Fusion/loop_fusion/src/pose_graph.cpp:474:52: error: cannot convert 'ceres::Manifold' to 'ceres::LocalParameterization' in initialization

             AngleLocalParameterization::Create();
                                                ^`

Solution:

            ceres::Manifold* angle_local_parameterization =
                AngleLocalParameterization::Create();

However, the above method did not allow VINS-Fusion to receive the correct data in the end, and it was implemented after downgrading ceres, the version is 1.14. If there are readers who have used the above method successfully, please let me know in the comments~

Welcome to point out mistakes and deficiencies~

Please indicate the source!

This article was published on the following blogs or websites:

Pisces Alpaca - Knowing (zhihu.com)

Pisces Alpaca Blog - CSDN Blog

Pisces Alpaca Develop Paper

Pisces Alpaca Profile - News - Nuggets (juejin.cn)

[Pisces Alpaca - Blog Park (cnblogs.com)](

Posted by Jtech inc. on Wed, 19 Oct 2022 18:18:14 +1030