乐趣区

关于学习:XTDrone和PX4学习期间问题记录一

XTDrone 和 PX4 学习期间问题记录(一)

Written By PiscesAlpaca

前言:

呈现问题能够去官方网站 http://ceres-solver.org/index… 查看文档,搜索引擎很难搜到对应的问题。(不过我写了这些问题的解决办法,没准当前就能搜到了 hh

1. 视觉 SLAM 篇

URL:视觉 SLAM · 语雀

ORBSLAM2 编译

编译依赖见 ORBSLAM2 编译依赖

留神该 ORBSLAM2 是在原版本根底上略做批改,其尽管反对 ROS,但不是规范的 ROS 架构,因而不能采纳 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 #将这句放到~/.bashrc 中,当前应用更不便
chmod +x build_ros.sh
./build_ros.sh

问题:在进行./build.sh 时,遇到了make[2]: *** No rule to make target '../Thirdparty/DBoW2/lib/libDBoW2.so', needed by '../lib/libORB_SLAM3.so'. Stop.

解决办法:手动 cd 进目录 ORB_SLAM3/Thirdparty/DBoW2/build,顺次运行cmake ..build -j4,之后就能够发现 libDBoW2.so 文件生成在 lib 目录下,再依照教程运行./build.sh 即可 100% 实现编译。

2. 三维激光 SLAM 篇

问题:在进行 catkin_make 命令时,遇到了 `/home/pisces/catkin_ws/src/A- LOAM/src/laserOdometry.cpp:286:29: error: expected type-specifier
286 | new ceres::EigenQuaternionParameterization();

  |                             ^~~~~                                   `

解决办法:

官网文档显示

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

证实 EigenQuaternionParameterization 曾经过期,须要应用 EigenQuaternionManifold 替换,即:

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

替换为:“

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

3. 视觉惯性里程计

问题:

`/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;
             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~`

解决办法:更改 ceres::LocalParameterization* 为 ceres::Manifold*

        ceres::Manifold* quaternionParameterization =
            new EigenQuaternionParameterization;

问题:

`/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`

解决办法:

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

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

问题:

`/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();
                                                                    ^~~~~`

解决办法:

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

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

问题:

`/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;
             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~`

解决办法:实质是因为新继承的 Manifold 类呈现了新的纯虚函数,只须要在 EigenQuaternionParameterization 类实现就行

在 EigenQuaternionParameterization 类 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;}

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;
};

问题:

`/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,
                    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~`

解决办法:

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

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

留神:如果进行更改后编译提醒短少 Plus 和 Minus 函数,能够在 pose_graph.h 文件退出

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 为减少的函数

问题:

`/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

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

解决办法:更改 ceres::LocalParameterization* 为 ceres::Manifold*

同本节问题 1

问题:

`/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();
                                                ^`

解决办法:

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

不过上述办法最终没有可能让 VINS-Fusion 接管到正确数据,还是对 ceres 进行了降级才实现,版本为 1.14。如果有应用上述办法胜利的读者能够在评论通知我~

欢送指出谬误和有余~

转载请注明出处!

本篇公布在以下博客或网站:

双鱼座羊驼 – 知乎 (zhihu.com)

双鱼座羊驼的博客_CSDN 博客

双鱼座羊驼 – SegmentFault 思否

双鱼座羊驼 的个人主页 – 动静 – 掘金 (juejin.cn)

双鱼座羊驼 – 博客园 (cnblogs.com)

退出移动版