ORB SLAM2_with_pointcloud_map编译&运行

由于开源版本的orbslam2没有地图的生成和保存模块,高博加了一个实时显示点云模块。

1、下载源码

git clone https://github.com/gaoxiang12/ORBSLAM2_with_pointcloud_map.git

2、解压 orbslam2_modified.zip
解压会得到两个文件夹,分别为 g2o_with_orbslam2 和 ORB_SLAM2_modified,与原ORB_SLAM2_modified合并到同一个文件夹

3、编译g2o_with_orbslam2

cd g2o_with_orbslam2
mkdir build
cmake ..
make -j8
sudo make install

–遇到编译错误时,作如下修改:
(1)解决办法:其实是版本问题,在这个网站上https://launchpad.net/ubuntu/trusty/amd64/libeigen3-dev/3.2.0-8,下载.deb文件,
然后安装:sudo dpkg -i libeigen3-dev_3.2.0-8_all.deb
或者:
(2)打开/g2o_with_orbslam2/g2o/types/slam2d/edge_se2_pointxy_bearing.cpp

//t.setRotation(t.rotation().angle()+_measurement);
改为:
t.setRotation((Eigen::Rotation2Dd)(t.rotation().angle()+_measurement));  

(3)打开/g2o_with_orbslam2/g2o/solvers/eigen/linear_solver_eigen.h

//typedef Eigen::PermutationMatrix PermutationMatrix;
改为:
//typedef Eigen::PermutationMatrix PermutationMatrix;
typedef Eigen::PermutationMatrix PermutationMatrix;

4、编译DBoW2

cd ORB_SLAM2_modified/Thirdparty/DBoW2
mkdir build
cd build
cmake .. -DCMAKE_BUILD_TYPE=Release
make 
#sudo make install

5、进入/ORB_SLAM2_modified文件夹

chmod +x build.sh
./build.sh

(1)–opencv版本错误进入CMakeLists.txt修改。
(2)–如果遇见DBoW2和g2o错误,例如报optimizer.cc未引用或者指针错误,作如下修改:
进入Thirdparty文件下,删除DBoW2和g2o里面的build文件
回到/ORB_SLAM2_modified文件夹,重新编译:./build.sh

6.用单目/双目/rgbd来做做实验
将数据集以及associate.py,放在 ORB_SLAM2_modified目录下,运行如下命令:

python associate.py Data/rgbd_dataset_freiburg1_desk/rgb.txt Data/rgbd_dataset_freiburg1_desk/depth.txt > Data/rgbd_dataset_freiburg1_desk/associations.txt

执行完毕后可运行示例:

./Example/RGB-D/rgbd_tum
      Vocabulary/ORBvoc.txt      path_to_settings     path_to_sequence    path_to_association
例如:
    ./Examples/RGB-D/rgbd_tum Vocabulary/ORBvoc.txt Examples/RGB-D/TUM1.yaml Data/rgbd_dataset_freiburg1_desk Data/rgbd_dataset_freiburg1_desk/associations.txt

7.简单保存最终点云
打开ORB_SLAM2_modified/pointcloudmapping.cc文件,做一点修改:
(1)添加头文件#include
(2)修改void PointCloudMapping::viewer()如下:

void PointCloudMapping::viewer()
{
    pcl::visualization::CloudViewer viewer("viewer");
    while(1)
    {
        {
            unique_lock lck_shutdown( shutDownMutex );
            if (shutDownFlag)
            {
                break;
            }
        }
        {
            unique_lock lck_keyframeUpdated( keyFrameUpdateMutex );
            keyFrameUpdated.wait( lck_keyframeUpdated );
        }
        // keyframe is updated 
        size_t N=0;
        {
            unique_lock lck( keyframeMutex );
            N = keyframes.size();
        }      
        for ( size_t i=lastKeyframeSize; iswap( *tmp );
        viewer.showCloud( globalMap );
        cout<<"show global map, size="<points.size()<

参考自:
https://blog.csdn.net/qq_25349629/article/details/88528765
https://blog.csdn.net/u011813286/article/details/89096065
https://blog.csdn.net/qq_25349629/article/details/88350374
https://blog.csdn.net/LOVE1055259415/article/details/79903571
https://blog.csdn.net/oliongs/article/details/79696376
https://github.com/abhineet123/ORB_SLAM2

你可能感兴趣的:(PnP/Slam)