Ubuntu18.04安装灭霸SLAM:ORBSLAM3

这篇具有很好参考价值的文章主要介绍了Ubuntu18.04安装灭霸SLAM:ORBSLAM3。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。


1.写在前面

终于有时间好好整理一下最近跑通ORB-SLAM3的一些笔记了,在xavier上安装了一下谷歌拼音输入法,具体可以参考:AGX Xavier安装中文输入法
先说结论:
1)不建议安装最新版,安装时有许多坑需要填,即使填好了,运行时依然会有很多坑,比如依赖于最新版的opencv4.4等等,最新版链接为:UZ-SLAMLab/ORB_SLAM3,安装参考链接为:ORB-SLAM3 安装运行。

2)建议使用opencv3版本作为依赖,如果是请跳过第二步;如果不是,请看第二步,继续填坑。


2.安装依赖

2.1Pangolin

下载地址:Pangolin
安装方式:
Pangolin的依赖安装

# Required
# OpenGL (Desktop / ES / ES2)
sudo apt install libgl1-mesa-dev
# Glew
sudo apt install libglew-dev
# CMake
sudo apt install cmake

# Recommended
# Python2 / Python3, for drop-down interactive console
sudo apt install libpython2.7-dev
# Wayland
sudo apt install pkg-config
sudo apt install libegl1-mesa-dev libwayland-dev libxkbcommon-dev wayland-protocols

# Optional
# FFMPEG (For video decoding and image rescaling)
sudo apt install ffmpeg libavcodec-dev libavutil-dev libavformat-dev libswscale-dev libavdevice-dev
# DC1394 (For firewire input)
sudo apt install libdc1394-22-dev libraw1394-dev
# libuvc (For cross-platform webcam video input via libusb)
git://github.com/ktossell/libuvc.git
# libjpeg, libpng, libtiff, libopenexr (For reading still-image sequences)
sudo apt install libjpeg-dev libpng-dev libtiff5-dev libopenexr-dev

下载&编译:

git clone https://github.com/stevenlovegrove/Pangolin.git
cd Pangolin
mkdir build
cd build
cmake ..
make
sudo make install

2.2 Opencv

Opencv比较有意思,由于我下载的版本是ORBSLAMv3的版本,它是依赖的Opencv>=2.4.11,但是又要<4,但是此时我的电脑里是opencv4.1.5,因而我修改了源代码:ORBSLAMv3依赖opencv4可编译。
OpenCV安装方式
去官网下载OpenCV,如果从零开始的话建议安装OpenCV3的版本,这样会省去很多麻烦。
Ubuntu18.04安装灭霸SLAM:ORBSLAM3
下载后解压:

unzip opencv-3.4.15.zip

更新一下,准备开始安装OpenCV依赖库(不更新也行)

sudo apt-get update

一条指令完成所有的依赖库:

sudo apt-get install build-essential libgtk2.0-dev libavcodec-dev libavformat-dev libjpeg.dev libtiff4.dev libswscale-dev libjasper-dev

如果报错

error: unable to locate libjasper-dev    无法定位这个包libjasper-dev

解决办法是:执行如下指令

sudo add-apt-repository "deb http://security.ubuntu.com/ubuntu xenial-security main"
sudo apt update
sudo apt install libjasper1 libjasper-dev

编译OpenCV

cd opencv-3.4.15
mkdir build
cd build
make -j8##jx代表的是x核编译
sudo make install

添加库路径

sudo /bin/bash -c 'echo "/usr/local/lib" > /etc/ld.so.conf.d/opencv.conf'

更新系统库

sudo ldconfig

配置bash

sudo gedit /etc/bash.bashrc

在末尾粘贴如下两行代码

PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig  
export PKG_CONFIG_PATH 

保存,执行如下命令使得配置生效

source /etc/bash.bashrc 

更新

sudo updatedb  

检查版本

pkg-config --modversion opencv

如果没问题的话,就说明安装结束了。

2.3 Eigen3

Eigen的安装方式比较简单,一条命令即可:

#github 有个mirror,版本3.3.4 from 2017
git clone https://github.com/eigenteam/eigen-git-mirror
#安装
cd eigen-git-mirror
mkdir build
cd build
cmake ..
sudo make install
#安装后,头文件安装在/usr/local/include/eigen3/

2.4 boost

boost库应该在安装ros的时候已经安装过了
,但是如果报错误的话,需要重装一次。
下载:boost,选择一个版本。
Ubuntu18.04安装灭霸SLAM:ORBSLAM3
下载之后解压:

tar -xzvf boost_1_7x_0.tar.gz

解压之后进入解压出来的文件夹

然后执行这个脚本

sudo ./bootstrap.sh

执行完毕之后,你会发现又多了些文件

执行如下脚本

sudo ./b2 install

2.5 libssl-dev

一条命令即可

sudo apt-get install libssl-dev

3 ORB_SLAM3的编译和安装

3.1 源码编译

源码编译:
进入源码文件夹

cd ORB_SLAM3
chmod +x build.sh
./build.sh

注意查看脚本build.sh:

echo "Configuring and building Thirdparty/DBoW2 ..."
 
cd Thirdparty/DBoW2
mkdir build
cd build
cmake .. -DCMAKE_BUILD_TYPE=Release
make -j
 
cd ../../g2o
 
echo "Configuring and building Thirdparty/g2o ..."
 
mkdir build
cd build
cmake .. -DCMAKE_BUILD_TYPE=Release
make -j
 
cd ../../../
 
echo "Uncompress vocabulary ..."
 
cd Vocabulary
tar -xf ORBvoc.txt.tar.gz
 
 
echo "Configuring and building ORB_SLAM3 ..."
 
mkdir build
cd build
cmake .. -DCMAKE_BUILD_TYPE=Release
make -j

-j后面没有数字,说明是满线程在跑,如果卡顿的话,注意改一下少一点线程。

3.2 ros下编译

3.2.1 将源码中的 Examples/ROS/ORB_SLAM3 路径添加到ROS_PACKAGE_PATH环境变量中
# 打开 .bashrc file:gedit ~/.bashrc# 添加路径 , 
gedit ~/.bashrc
# 其中PATH是本机的具体路径(如/home/xxx)
export ROS_PACKAGE_PATH=${ROS_PACKAGE_PATH}:“PATH”/ORB_SLAM3/Examples/ROS
# 然后保存一下,一定要再source一下
source ~/.bashrc
3.2.2 执行build_ros.sh文件
chmod +x build_ros.sh
./build_ros.s

4.编译过程中遇到的问题

4.1 opencv4版本与ORB-SLAM3的各种冲突

4.1.1 Thirdparty/DBoW2和主函数的CMakeLists.txt里面的opencv版本路径要修改,改成自己的。

运行build.sh报错
Ubuntu18.04安装灭霸SLAM:ORBSLAM3
修改CMakeList.txt文件中的opencv:

find_package(OpenCV 3.0)
if(NOT OpenCV_FOUND)
   find_package(OpenCV 2.4.3 QUIET)
   if(NOT OpenCV_FOUND)
      message(FATAL_ERROR "OpenCV > 2.4.3 not found.")
   endif()
endif()

改正后:

find_package(OpenCV 4.0)
if(NOT OpenCV_FOUND)
   find_package(OpenCV 2.4.3 QUIET)
   if(NOT OpenCV_FOUND)
      message(FATAL_ERROR "OpenCV > 2.4.3 not found.")
   endif()
endif()

make时报错:
Ubuntu18.04安装灭霸SLAM:ORBSLAM3
解决方法就是把 所有文件里面的

#include <opencv/cv.h>

换成

#include <opencv2/imgproc.hpp>

4.2 错误 ‘CV_LOAD_IMAGE_UNCHANGED’ was not declared in this scope119 | imLeft = cv::imread(vstrImageLeft[ni],CV_LOAD_IMAGE_UNCHANGED);

解决办法:打开vscode,查找所有存在CV_LOAD_IMAGE_UNCHANGED的文件,添加头文件:

#include "opencv2/imgcodecs/legacy/constants_c.h"

4.3 报错:std::map must have the same value_type as its allocator

解决方法:
在LoopClosing.h中修改

typedef map<KeyFrame*,g2o::Sim3,std::less<KeyFrame*>,
        Eigen::aligned_allocator<std::pair<const KeyFrame*, g2o::Sim3> > > KeyFrameAndPose;

typedef map<KeyFrame*,g2o::Sim3,std::less<KeyFrame*>,
        Eigen::aligned_allocator<std::pair<KeyFrame* const, g2o::Sim3> > > KeyFrameAndPose;

4.4 错误:‘CvMat’ has not been declared/‘CV_GRAY2BGR’ was not declared in this scope error: ‘CV_RGB2GRAY’ was not declared in this scope

解决办法:
同样打开vscode,查找所有存在CV_RGB2GRAY的文件,添加以下头文件即可:

#include <opencv2/imgproc/types_c.h>

4.5 错误CMake Deprecation Warning at /opt/ros/melodic/share/ros/core/rosbuild/rosbuild.cmake:7 (cmake_policy):

Building ROS nodes
mkdir: cannot create directory ‘build’: File exists
CMake Deprecation Warning at /opt/ros/melodic/share/ros/core/rosbuild/rosbuild.cmake:7 (cmake_policy):
  The OLD behavior for policy CMP0011 will be removed from a future version
  of CMake.

  The cmake-policies(7) manual explains that the OLD behaviors of all
  policies are deprecated and that a policy should be set to OLD only under
  specific short-term circumstances.  Projects should be ported to the NEW
  behavior and not rely on setting a policy to OLD.
Call Stack (most recent call first):
  CMakeLists.txt:2 (include)


CMake Deprecation Warning at /opt/ros/melodic/share/ros/core/rosbuild/rosbuild.cmake:16 (cmake_policy):
  The OLD behavior for policy CMP0002 will be removed from a future version
  of CMake.

  The cmake-policies(7) manual explains that the OLD behaviors of all
  policies are deprecated and that a policy should be set to OLD only under
  specific short-term circumstances.  Projects should be ported to the NEW
  behavior and not rely on setting a policy to OLD.
Call Stack (most recent call first):
  CMakeLists.txt:2 (include)


CMake Deprecation Warning at /opt/ros/melodic/share/ros/core/rosbuild/rosbuild.cmake:18 (cmake_policy):
  The OLD behavior for policy CMP0003 will be removed from a future version
  of CMake.

  The cmake-policies(7) manual explains that the OLD behaviors of all
  policies are deprecated and that a policy should be set to OLD only under
  specific short-term circumstances.  Projects should be ported to the NEW
  behavior and not rely on setting a policy to OLD.
Call Stack (most recent call first):
  CMakeLists.txt:2 (include)


CMake Deprecation Warning at /opt/ros/melodic/share/ros/core/rosbuild/rosbuild.cmake:20 (cmake_policy):
  The OLD behavior for policy CMP0005 will be removed from a future version
  of CMake.

  The cmake-policies(7) manual explains that the OLD behaviors of all
  policies are deprecated and that a policy should be set to OLD only under
  specific short-term circumstances.  Projects should be ported to the NEW
  behavior and not rely on setting a policy to OLD.
Call Stack (most recent call first):
  CMakeLists.txt:2 (include)


CMake Deprecation Warning at /opt/ros/melodic/share/ros/core/rosbuild/rosbuild.cmake:23 (cmake_policy):
  The OLD behavior for policy CMP0011 will be removed from a future version
  of CMake.

  The cmake-policies(7) manual explains that the OLD behaviors of all
  policies are deprecated and that a policy should be set to OLD only under
  specific short-term circumstances.  Projects should be ported to the NEW
  behavior and not rely on setting a policy to OLD.
Call Stack (most recent call first):
  CMakeLists.txt:2 (include)


[rosbuild] Building package ORB_SLAM3
Failed to invoke /opt/ros/melodic/bin/rospack deps-manifests ORB_SLAM3
Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/rosdep2/rospack.py", line 60, in init_rospack_interface
    lookup = _get_default_RosdepLookup(Options())
  File "/usr/lib/python2.7/dist-packages/rosdep2/main.py", line 136, in _get_default_RosdepLookup
    verbose=options.verbose)
  File "/usr/lib/python2.7/dist-packages/rosdep2/sources_list.py", line 609, in create_default
    sources = load_cached_sources_list(sources_cache_dir=sources_cache_dir, verbose=verbose)
  File "/usr/lib/python2.7/dist-packages/rosdep2/sources_list.py", line 566, in load_cached_sources_list
    raise CachePermissionError('Failed to write cache file: ' + str(e))
rosdep2.core.CachePermissionError: Failed to write cache file: [Errno 13] Permission denied: '/home/nvidia/.ros/rosdep/sources.cache/index'
[rospack] Error: could not call python function 'rosdep2.rospack.init_rospack_interface'


CMake Error at /opt/ros/melodic/share/ros/core/rosbuild/public.cmake:129 (message):
  

  Failed to invoke rospack to get compile flags for package 'ORB_SLAM3'.
  Look above for errors from rospack itself.  Aborting.  Please fix the
  broken dependency!

Call Stack (most recent call first):
  /opt/ros/melodic/share/ros/core/rosbuild/public.cmake:207 (rosbuild_invoke_rospack)
  CMakeLists.txt:4 (rosbuild_init)


-- Configuring incomplete, errors occurred!
See also "/home/nvidia/ORB_SLAM3/catkin_ws/src/ORB_SLAM3-v0.3-beta/Examples/ROS/ORB_SLAM3/build/CMakeFiles/CMakeOutput.log".
make: *** No targets specified and no makefile found.  Stop.

这个错误的原因时因为,没有写入环境变量里面,但是写入后同时也报这个错误,那么需要rosdep一下,推荐使用鱼香ros的rosdep方法。
最简单的ROS安装方法和rosdepc安装(一行代码搞定)
具体方法是:

curl http://fishros.com/tools/install/rosdepc | bash 
sudo rosdep fix-permissions
rosdep update

4.6.如果是卸载重装报错[rosbuild] Building package ORB_SLAM3

[rosbuild] Error from directory check: /opt/ros/melodic/share/ros/core/rosbuild/bin/check_same_directories.py /opt/ros/melodic/share/ORB_SLAM3 /home/nvidia/ORB_SLAM3-v0.3-beta/Examples/ROS/ORB_SLAM3
1
Traceback (most recent call last):
File “/opt/ros/melodic/share/ros/core/rosbuild/bin/check_same_directories.py”, line 48, in
raise Exception
Exception
CMake Error at /opt/ros/melodic/share/ros/core/rosbuild/private.cmake:99 (message):
[rosbuild] rospack found package “ORB_SLAM3” at
“/opt/ros/melodic/share/ORB_SLAM3”, but the current directory is
“/home/nvidia/ORB_SLAM3-v0.3-beta/Examples/ROS/ORB_SLAM3”. You should
double-check your ROS_PACKAGE_PATH to ensure that packages are found in the
correct precedence order.
Call Stack (most recent call first):
/opt/ros/melodic/share/ros/core/rosbuild/public.cmake:177 (_rosbuild_check_package_location)
CMakeLists.txt:4 (rosbuild_init)

– Configuring incomplete, errors occurred!
See also “/home/nvidia/ORB_SLAM3-v0.3-beta/Examples/ROS/ORB_SLAM3/build/CMakeFiles/CMakeOutput.log”.
make: *** No targets specified and no makefile found. Stop.

解决办法,找到所有关于ORB_SLAM3的安装文件并且删除:

cd /opt/ros/melodic/share/ORB_SLAM3
nvidia@MiWiFi-R1CM-srv:/opt/ros/melodic/share/ORB_SLAM3$ ls
Asus.yaml       lib           MonoAR         RGBD    Stereo_Inertial
build           manifest.xml  Mono_Inertial  src
CMakeLists.txt  Mono          ORB_SLAM3      Stereo

cd ..
sudo rm -rf ORB_SLAM3

5 写在最后

运行命令:

纯单目

  rosrun ORB_SLAM3 Mono PATH_TO_VOCABULARY PATH_TO_SETTINGS_FILE

单目+IMU

rosrun ORB_SLAM3 Mono PATH_TO_VOCABULARY PATH_TO_SETTINGS_FILE [EQUALIZATION]	

纯双目

rosrun ORB_SLAM3 Stereo PATH_TO_VOCABULARY PATH_TO_SETTINGS_FILE ONLINE_RECTIFICATION

其中ONLINE_RECTIFICATION为在线的意思

双目+IMU

rosrun ORB_SLAM3 Stereo_Inertial PATH_TO_VOCABULARY PATH_TO_SETTINGS_FILE ONLINE_RECTIFICATION [EQUALIZATION]	

纯RGB-D相机

rosrun ORB_SLAM3 RGBD PATH_TO_VOCABULARY PATH_TO_SETTINGS_FILE

ROS下的例子如

roscore
rosrun ORB_SLAM3 Stereo_Inertial Vocabulary/ORBvoc.txt Examples/Stereo-Inertial/EuRoC.yaml true
 rosbag play --pause V1_02_medium.bag /cam0/image_raw:=/camera/left/image_raw /cam1/image_raw:=/camera/right/image_raw /imu0:=/imu

参考链接:
1.ubuntu20.04装ORB-slam2 和ORB-slam2-ros
2.ORB-SLAM3 安装运行
3.初学尝试 Ubuntu 18.04 运行 ORB-SLAM3 demo
4.ORBSLAM2 安装与运行(Ubuntu 18.04下测试)文章来源地址https://www.toymoban.com/news/detail-406651.html

到了这里,关于Ubuntu18.04安装灭霸SLAM:ORBSLAM3的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

  • ubuntu18.04配置ORB-SLAM3并跑EuRoC数据集(单目)

    1.1  C++11 or C++0x Compiler 安装 新建一个终端(新建终端的快捷键是Ctrl+Alt+T) 输入以下代码 sudo apt-get install gcc sudo apt-get install g++ sudo apt-get install build-essential sudo apt-get install cmake 1.2  Pangolin 安装 Pangolin的官方教程地址:https://github.com/stevenlovegrove/Pangolin 安装Pangolin 1.2.1下载

    2023年04月20日
    浏览(45)
  • Ubuntu18.04版本下配置ORB-SLAM3和数据集测试方法

    使用:VMware Workstation Pro 虚拟机系统版本是:Ubuntu 18.04.06 虚拟机内存:8g(若为4g大小,很容易出现后文中ORB-SLAM3编译时会出现的内存问题) 虚拟机存储:50g 若是配置完发现存储空间不足,可以参考这篇博客进行清理: 下载配置技巧:Ubuntu18.04安装vmware-tools解决无法复制粘贴

    2024年02月09日
    浏览(41)
  • Ubuntu18.04:ORB-SLAM3使用数据集构建地图和保存点云地图

    在前一篇文章的Ubuntu18.04版本下配置ORB-SLAM3和数据集测试方法中,Ubuntu18.04的系统下成功配置完成了ORB-SLAM3,在ORB_SLAM3目录下输入命令: 即可在线构建地图,但是即使程序运行完成,也看不见地图文件,它在哪里? 原因:ORB-SLAM3并不会自己保存构建的点云地图文件。 若是想要

    2024年02月09日
    浏览(97)
  • Ubuntu18.04下使用安卓手机Camera和IMU信息运行ORB-SLAM2

    1、下载Android_Camera-IMU,将其中的Camera-Imu.apk文件发送至手机端进行安装。 下载命令: git clone https://github.com/hitcm/Android_Camera-IMU.git  发送至手机的文件在手机端安装以后的软件  在手机端安装好以后的软件如下:  2、安装功能依赖包:sudo apt-get install ros-melodic-imu-tools  # 修改

    2024年02月09日
    浏览(35)
  • Linux系统 Ubuntu18.04安装的详细教程(提供18.04ubuntu镜像)

    镜像文件下载: 链接:https://pan.baidu.com/s/12bEdRBwO1YbLt23QKnrSrA 提取码:h7as 关于全名、用户名区别可先看第四部分 处理器和内核数量,根据需要配置就行。我是8核16线程,配置2,2。小白学习的话,配置低一点没关系。如果你只是为了学一些基础命令,配置成1,1应该也没问题

    2024年02月01日
    浏览(48)
  • Ubuntu18.04 ROS melodic环境下,通过Gazebo软件仿真SLAM算法的学习(gmapping/karto/cartographer/hector)

    目录 一 环境场景搭建world 1.下载insert插件(该插件下会提供一些建好的场景,也可不下载) 2.环境搭建(自建) 3.保存环境 4.配置修改 5.启动环境 二 机器人模型URDF 1.模型创建的文件书写规范 2.检查文件格式是否正确 3.启动模型 三 机器人在场景中运动 1.机器人放在场景中

    2024年02月04日
    浏览(31)
  • Ubuntu18.04跑通ORB_SLAM3(实时USB单目摄像头&本地视频.mp4&官方数据集)

    本人小白,寒假期间学习了一些ROS知识,试着在虚拟机搭建ORB_SLAM3环境并跑通数据集和摄像头,作本文以记录学习过程。所有用到的资源(软件安装包,镜像文件,库的源码文件都会放在最后百度网盘链接里) 目录 0.something you should know 1.安装VMware Workstation Pro和Ubuntu18.04 2.安

    2023年04月18日
    浏览(54)
  • ubuntu 18.04 安装pcl

    Ubuntu18.04安装PCL(详细教程)_pcl ubuntu_一盆柠檬的博客-CSDN博客

    2024年02月12日
    浏览(41)
  • ubuntu18.04安装部署环境

    更新apt源 下载mysql-server 查看mysql的状态 进入mysql终端 设置root密码 登录mysql 回到不用密码的方式登录 添加账户 root账号远程访问 下载redis-server 检查redis服务状态 修改配置文件开启远程连接 重启服务 下载nginx 配置文件夹 启动nginx服务

    2024年02月01日
    浏览(44)
  • ubuntu 18.04安装docker

    from:Install Docker Engine on Ubuntu | Docker Documentation Install from a package If you can’t use Docker’s  apt  repository to install Docker Engine, you can download the  deb  file for your release and install it manually. You need to download a new file each time you want to upgrade Docker Engine. Go to Index of linux/ubuntu/dists/. Select your

    2024年02月05日
    浏览(53)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包