场景:
编译高翔博士的ORBSLAM2_with_pointcloud_map
它的过程为:
Unzip the file you will find two directories. First compile the modified g2o:
cd g2o_with_orbslam2
mkdir build
cd build
cmake …
make
Following the instructions from the original g2o library: [https://github.com/RainerKuemmerle/g2o] if you have dependency problems. I just add the extra vertecies and edges provided in ORB_SLAM2 intog2o.
Then compile the ORB_SLAM2. You need firstly to compile the DBoW2 in ORB_SLAM2_modified/Thirdpary, and then the Pangolin module (https://github.com/stevenlovegrove/Pangolin). Finally, build ORB_SLAM2:
cd ORB_SLAM2_modified
mkdir build
cd build
cmake …
make
To run the program you also need to download the ORB vocabulary (which is a large file so I don’t upload it) in the original ORB_SLAM2 repository.
问题描述
编译g2o_with_orbslam2遇到的问题汇总以及解决方法
参考网页:
https://blog.csdn.net/weixin_39752599/article/details/86564808
https://www.cnblogs.com/wjx-zjut/p/7107217.html
https://blog.csdn.net/gaiyonghuming110/article/details/103245061
https://www.cnblogs.com/haijian/p/10788141.html
解决方案:
问题1
报错信息:
ORBSLAM2_with_pointcloud_map/orbslam2_modified/g2o_with_orbslam2/g2o/types/slam2d/edge_se2_pointxy_bearing.cpp: In member function ‘virtual void g2o::EdgeSE2PointXYBearing::initialEstimate(const VertexSet&, g2o::OptimizableGraph::Vertex*)’:
/home/robot/g2o/g2o/types/slam2d/edge_se2_pointxy_bearing.cpp:50:52: error: no matching function for call to ‘g2o::SE2::setRotation(Eigen::Rotation2D::Scalar)’
t.setRotation(t.rotation().angle()+_measurement);
处理方法:
In g2o/types/slam2d/edge_se2_pointxy_bearing.cpp
change:
t.setRotation(t.rotation().angle()+_measurement);
to
t.setRotation((Eigen::Rotation2Dd)(t.rotation().angle()+_measurement));
问题2:
报错信息:
/usr/include/eigen3/Eigen/src/Core/util/StaticAssert.h:32: error: static assertion failed: YOU_MIXED_DIFFERENT_NUMERIC_TYPES__YOU_NEED_TO_USE_THE_CAST_METHOD_OF_MATRIXBASE_TO_CAST_NUMERIC_TYPES_EXPLICITLY
#define EIGEN_STATIC_ASSERT(X,MSG) static_assert(X,#MSG);
处理方法:
打开g2o/solvers/linear_solver_eigen.h,将以下代码:
template
class LinearSolverEigen: public LinearSolver
{
public:
typedef Eigen::SparseMatrix<double, Eigen::ColMajor> SparseMatrix;
typedef Eigen::Triplet Triplet;
typedef Eigen::PermutationMatrix<Eigen::Dynamic, Eigen::Dynamic, SparseMatrix::Index> PermutationMatrix;
改成
template
class LinearSolverEigen: public LinearSolver
{
public:
typedef Eigen::SparseMatrix<double, Eigen::ColMajor> SparseMatrix;
typedef Eigen::Triplet Triplet;
typedef Eigen::PermutationMatrix<Eigen::Dynamic, Eigen::Dynamic, int> PermutationMatrix;
问题3:
报错信息:
‘MatrixExponential’ is not a member of ‘Eigen’
处理方法:
// bigB = expm(bigA)
//Eigen::MatrixExponential me(bigA);
//me.compute(bigB);
bigB = bigA.exp();
前三行代码注释掉,添加最后一行
问题4:
报错信息:
ORBSLAM2_with_pointcloud_map/orbslam2_modified/g2o_with_orbslam2/g2o/examples/tutorial_slam2d/simulator.cpp:80:39: required from here
/usr/include/eigen3/Eigen/src/Core/util/StaticAssert.h:32:40: error: static assertion failed: FLOATING_POINT_ARGUMENT_PASSED__INTEGER_WAS_EXPECTED
#define EIGEN_STATIC_ASSERT(X,MSG) static_assert(X,#MSG);
处理方法:
g2o/g2o/examples/tutorial_slam2d/simulator.cpp: 80行
VectorXd probLimits(MO_NUM_ELEMS); —>>>
VectorXd probLimits; probLimits.resize(MO_NUM_ELEMS);