Ubuntu20.04 SLAM第三方库安装

本文涉及的主要内容

本文基于《视觉SLAM十四讲》内容,安装一些第三方库,主要有:Pangolin、Sophus、OpenCV、Ceres-Solver、g2o、DBoW3、gtsam、fmt等。

Pangolin

# Get Pangolin, use latest stable branch recommended
cd ~/your_fav_code_directory
git clone --recursive https://github.com/stevenlovegrove/Pangolin.git -b v0.8
cd Pangolin

# Dependencies
# See what package manager and packages are recommended
# ./scripts/install_prerequisites.sh --dry-run recommended
# Override the package manager choice and install all packages
# ./scripts/install_prerequisites.sh -m brew all

# Install dependencies (as described above, or your preferred method)
./scripts/install_prerequisites.sh recommended

# Configure and build
cmake -B build
cmake --build build

# with Ninja for faster builds (sudo apt install ninja-build)
cmake -B build -GNinja
cmake --build build
sudo make install
# GIVEME THE PYTHON STUFF!!!! (Check the output to verify selected python version)
# cmake --build build -t pypangolin_pip_install

# Run me some tests! (Requires Catch2 which must be manually installed on Ubuntu.)
# ctest

Sophus

# 获取源码
git clone https://github.com/strasdat/Sophus.git

# 编译安装
cd Sophus
cmake -B build
cmake --build build
cd build && sudo make install

OpenCV

# get source code
git clone https://github.com/opencv/opencv

# build && install
mkdir build && cd build
cmake ..
make
sudo make install

遇到问题:

modules/python/src2/cv2.cpp:885:34: error: invalid conversion from ‘const char*’ to ‘char*’ [-fpermissive]
char* str = PyString_AsString(obj);
modules/python3/CMakeFiles/opencv_python3.dir/build.make:62: recipe for target 'modules/python3/CMakeFiles/opencv_python3.dir/__/src2/cv2.cpp.o' failed
make[2]: *** [modules/python3/CMakeFiles/opencv_python3.dir/__/src2/cv2.cpp.o] Error 1
CMakeFiles/Makefile2:5446: recipe for target 'modules/python3/CMakeFiles/opencv_python3.dir/all' failed
make[1]: *** [modules/python3/CMakeFiles/opencv_python3.dir/all] Error 2
Makefile:162: recipe for target 'all' failed
make: *** [all] Error 2

解决办法:
编辑报错文件:/your/path/of/opencv/modules/python/src2/cv2.cpp第885行

// before
bool pyopencv_to(PyObject* obj, String& value, const char* name)
{
    (void)name;
    if(!obj || obj == Py_None)
        return true;
    char* str = PyString_AsString(obj); // This is row 885.
    if(!str)
        return false;
    value = String(str);
    return true;
}
// after
bool pyopencv_to(PyObject* obj, String& value, const char* name)
{
    (void)name;
    if(!obj || obj == Py_None)
        return true;
    const char* str = PyString_AsString(obj);
    if(!str)
        return false;
    value = String(str);
    return true;
}

Ceres-Solver

# install dependences
sudo apt install libgoogle-glog-dev libatlas-base-dev libeigen3-dev libsuitesparse-dev libsuitesparse-dev liblapack-dev libcxsparse3.1.2 libgflags-dev libgtest-dev

# get source code
git clone https://github.com/ceres-solver/ceres-solver.git

# build && install
cd ceres-solver
cmake -B build
cmake --build build
cd build && sudo make install

g2o

# install dependences
sudo apt install libeigen3-dev qtdeclarative5-dev qt5-qmake libqglviewer-dev

# get source code
git clone https://github.com/RainerKuemmerle/g2o.git

# build & install
cd g2o
mkdir build
cd build
cmake ..
make
sudo make install

gtsam

# get source code
git clone https://bitbucket.org/gtborg/gtsam.git

# install dependences
sudo apt-get install libboost-all-dev libtbb-dev

# build & install
mkdir build
cd build
cmake ..
make check (optional, runs unit tests)
sudo make install

DBow3

DBow3依赖OpenCV,因此需要注意需要先编译安装OpenCV,再编译DBow3。

# get source code
git clone https://github.com/rmsalinas/DBow3

# build & install
mkdir build
cd build
cmake ..
make
sudo make install

fmt

# get source code
git clone https://github.com/fmtlib/fmt.git
cd fmt
# build & install
mkdir build && cd build
cmake -DBUILD_SHARED_LIBS=TRUE ..
sudo make install
  • 5
    点赞
  • 19
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
Ubuntu 20.04是一个操作系统,而SLAM(即Simultaneous Localization and Mapping)是一种用于同时定位和地图构建的技术。为了在Ubuntu 20.04中搭建SLAM环境,你可以遵循以下步骤: 1. 首先,你需要安装一些第三方库。根据引用中提到的内容,你需要安装以下:Pangolin、Sophus、OpenCV、Ceres-Solver、g2o、gtsam、DBow3和fmt。你可以通过在终端中运行相应的命令来安装这些。例如,运行以下命令来安装Pangolin: sudo apt-get install libpangolin-dev 2. 根据引用中提到的官网链接,你可以在ROS官方网站上找到关于在Ubuntu 20.04安装OpenCV的详细说明。按照官方文档中给出的步骤,你可以安装OpenCV。 3. 在使用Pangolin时,如果遇到"Could NOT find GLEW"错误,你可以按照引用中的建议运行以下命令来安装libglew-dev: sudo apt-get install libglew-dev 通过按照以上步骤安装所需的第三方库和软件,你就可以搭建一个基本的Ubuntu 20.04 SLAM环境了。请记住,具体的安装步骤可能会因的版本和其他因素而略有不同,所以在实际操作中请仔细阅读相关文档并根据实际情况进行调整。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* [Ubuntu20.04 SLAM第三方库安装](https://blog.csdn.net/weixin_42068573/article/details/124949127)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] - *2* *3* [Ubuntu20.04配置SLAM环境](https://blog.csdn.net/weixin_41954990/article/details/128616085)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值