注:文末包含该文章涉及的所有安装包的网盘链接
零、换源(也可以先不换,后面觉得下载慢再换也行)
1、备份原来的源
sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak
2、打开源保存文件
sudo gedit /etc/apt/sources.list #(可将gedit更换为自己熟悉的编辑器 - vim)
3、换源(换其中一个就行,也可以去搜别的源)
#添加阿里源
deb http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse
#添加清华源
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-updates main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-updates main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-backports main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-backports main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-security main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-security main restricted universe multiverse multiverse
4、更新源
sudo apt-get update
sudo apt-get upgrade
一、安装git(克隆源代码)、gedit(编辑文本)、cmake、gcc、g++、build-essential
sudo apt-get install git
sudo apt-get install gedit
sudo apt-get install camke
sudo apt-get install gcc
sudo apt-get install g++
sudo apt-get install build-essential
二、安装Pangolin-0.5 (手动安装)==> Pangolin-0.5.tar.gz
1、前置依赖:
sudo apt install libgl1-mesa-dev
sudo apt install libglew-dev
sudo apt install libpython2.7-dev
sudo apt install pkg-config
sudo apt install libegl1-mesa-dev libwayland-dev libxkbcommon-dev wayland-protocols
2、解压文件 && 安装
cd Pangolin-0.5
sudo mkdir build
cd build
sudo cmake .. #有的地方写 cmake -DCPP11_NO_BOOSR=1 .. 也可以,#待验证区别
sudo make #有的地方写 cmake --build . 也是一样的
sudo make install (这个也是需要的,网上很多教程没有这个命令)
三、安装OpenCV(版本:opencv-3.4.15.zip)下载的文件直接放根目录下
1、前置依赖:
sudo apt-get install build-essential libgtk2.0-dev libavcodec-dev libavformat-dev libjpeg.dev libtiff5.dev libswscale-dev libjasper-dev
出现error: E: 无法定位软件包 libjasper-dev
解决办法:
sudo add-apt-repository "deb http://security.ubuntu.com/ubuntu xenial-security main"
sudo apt update
sudo apt upgrade
sudo apt install libjasper1 libjasper-dev
再重新配置前置依赖(已经配置了libjasper-dev,不用重新配置)。
2、解压文件 && 安装
unzip opencv-3.4.15.zip
cd opencv-3.4.15
sudo mkdir build
cd build
sudo cmake ..
sudo make
sudo make install
四、安装eigen(版本:eigen-3.2.9.tar.gz)下载的文件直接放根目录下
1、解压文件 && 安装
tar -zxvf eigen-3.2.9.tar.gz #解压
cd eigen3.2.9
sudo mkdir build
cd build
sudo cmake ..
sudo make install
五、安装Ceres(版本:ceres-solver-1.14.0-master.zip)下载的文件直接放根目录下
1、前置依赖:
# 安装相关依赖
sudo apt-get install cmake # CMake(前面安装了,跳过)
# google-glog + gflags
sudo apt-get install libgoogle-glog-dev libgflags-dev
# BLAS & LAPACK
sudo apt-get install libatlas-base-dev libsuitesparse-dev
sudo apt-get install libeigen3-dev # Eigen3(前面安装过eigen,应该不用运行下面的代码--我没运行也没报错)
# SuiteSparse and CXSparse (optional)
sudo apt-get install libsuitesparse-dev
2、解压文件 && 安装
unzip ceres-solver-1.14.0-master.zip #解压
cd ceres-solver-1.14.0-master
sudo mkdir build
cd build
sudo cmake ..
sudo make
sudo make install
如果 sudo cmake … 报错如下:
-- Configuring incomplete, errors occurred!
See also "/home/yaowei/ceres-solver-1.14.0-master/build/CMakeFiles/CMakeOutput.log".
See also "/home/yaowei/ceres-solver-1.14.0-master/build/CMakeFiles/CMakeError.log".
那可能是前置依赖没有安装完全,把前置依赖从新加载一遍。
六、安装ROS
1、添加sources.list
sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list'
2、添加keys
sudo apt-key adv --keyserver 'hkp://keyserver.ubuntu.com:80' --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654
3、更新
sudo apt update
4、安装ros-noetic-desktop-full --------不同版本不一样,这个是Ubuntu20.04版本的命令,其他版本自行搜索
sudo apt install ros-noetic-desktop-full
5、如果出现错误(E: Sub-process /usr/bin/dpkg returned an error code (1))
#我的错误如下:
dpkg: 处理归档 /var/cache/apt/archives/python3-catkin-pkg-modules_0.5.2-1_all.deb (--unpack)时出错:
正试图覆盖 /usr/lib/python3/dist-packages/catkin_pkg/__init__.py,它同时被包含于软件包 python3-catkin-pkg 0.4.16-1
在处理时有错误发生:
/var/cache/apt/archives/python3-catkin-pkg-modules_0.5.2-1_all.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)
#其他人类似的错误如下:正在解包 ros-melodic-desktop-full (1.4.1-0bionic.20220120.165755) ...
在处理时有错误发生:
/tmp/apt-dpkg-install-X1FdpB/346-python-catkin-pkg-modules_0.4.24-1_all.deb
/tmp/apt-dpkg-install-X1FdpB/370-python-rospkg-modules_1.4.0-1_all.deb
/tmp/apt-dpkg-install-X1FdpB/371-python-rosdistro-modules_0.8.3-1_all.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)
直接上最终的方法:
##在用apt-get安装软件包的时候遇到E: Sub-process /usr/bin/dpkg returned an error code (1)问题,解决方法如下:
cd /var/lib/dpkg/
sudo mv info/ info_bak # 现将info文件夹更名
sudo mkdir info # 再新建一个新的info文件夹
sudo apt-get update # 更新
sudo apt-get -f install # 修复
sudo mv info/* info_bak/ # 执行完上一步操作后会在新的info文件夹下生成一些文件,现将这些文件全部移到info_bak文件夹下
sudo rm -rf info # 把自己新建的info文件夹删掉
sudo mv info_bak info # 把以前的info文件夹重新改回名
sudo apt install ros-noetic-desktop-full #再次安装,基本就能够成功
实在不行推荐一篇博客:(46条消息) Ubuntu18.04 —— 安装环境及运行Vins_mono(2022年)vinsmono运行@曾记否的博客-CSDN博客 按照他的步骤一步一步测试。
6、初始化空间
sudo rosdep init
报错:sudo: rosdep:找不到命令
解决方案:
#打开hosts文件
sudo gedit /etc/hosts
#在文件末尾添加
151.101.84.133 raw.githubusercontent.com #raw.githubusercontent.com的ip会变化,最好自己查一下
#保存后退出再尝试
rosdep update
rosdep update 的结果:
ERROR: no sources directory exists on the system meaning rosdep has not yet been initialized.
Please initialize your rosdep with
sudo rosdep init
根据提示输入 sudo rosdep init 结果如下
Wrote /etc/ros/rosdep/sources.list.d/20-default.list
Recommended: please run
rosdep update
再次输入rosdep update 会出现新的错误,如下:
reading in sources list data from /etc/ros/rosdep/sources.list.d
Hit https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/osx-homebrew.yaml
Hit https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/base.yaml
Hit https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/python.yaml
Hit https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/ruby.yaml
ERROR: unable to process source [https://raw.githubusercontent.com/ros/rosdistro/master/releases/fuerte.yaml]:
Failed to download target platform data for gbpdistro:
The read operation timed out
Query rosdistro index https://raw.githubusercontent.com/ros/rosdistro/master/index-v4.yaml
ERROR: error loading sources list:
The read operation timed out (https://raw.githubusercontent.com/ros/rosdistro/master/index-v4.yaml)
解决方法参考博客:(46条消息) rosdep update — The read operation timed out 解决方法-CSDN博客
例如:
sudo gedit /etc/ros/rosdep/sources.list.d/20-default.list #打开文件
7、您必须在使用ROS的每个bash终端中获取此脚本的源代码
source /opt/ros/noetic/setup.bash
8、环境配置
echo "source /opt/ros/noetic/setup.bash" >> ~/.bashrc
source ~/.bashrc
9、查看环境配置(可有可无)
env | grep ROS
10、小海龟测试(打开三个命令行窗口)
roscore #第一个窗口
rosrun turtlesim turtlesim_node #第二个窗口 ----开启TurtleSim小乌龟的控制窗口
rosrun turtlesim turtle_teleop_key #第三个窗口 ----可以使用键盘上下左右键控制乌龟移动
一切正常即完成ROS的安装
七、安装&&运行VINS-Mono
1、下载编译VINS-Mono
mkdir catkin_ws
cd catkin_ws
mkdir src
cd src
git clone https://github.com/HKUST-Aerial-Robotics/VINS-Mono.git #git不下来可以直接去github下载压缩包解压安装,解压在 catkin_ws/src 目录下
cd ../
catkin_make
source ~/catkin_ws/devel/setup.bash
执行 catkin_make 会出以下错误:
make[1]: *** [CMakeFiles/Makefile2:1910:VINS-Mono-master/pose_graph/CMakeFiles/pose_graph.dir/all] 错误 2
make: *** [Makefile:141:all] 错误 2
Invoking "make -j8 -l8" failed
出现这个错误你就需要往上翻找错误了,错误如下:
解决方案:
参考博客(46条消息) opencv常见用法和opencv3->opencv4版本切换_opencv3 opencv4_xlsemmmmmm的博客-CSDN博客 版本之间存在差异,挨个按照文件修改即可。
2、下载数据集(EuRoC数据集链接:kmavvisualinertialdatasets – ASL Datasets (ethz.ch))
下载bag包
将下载的数据包放在catkin_ws目录下:
3、开始使用EuRoC数据集运行VINS_Mono
在catkin_ws目录下开三个命令行终端窗口
#第一个窗口
source devel/setup.bash
roslaunch vins_estimator euroc.launch
#第二个窗口
source devel/setup.bash
roslaunch vins_estimator vins_rviz.launch
#第三个窗口
source devel/setup.bash
rosbag play MH_01_easy.bag #实际应该是rosbag play YOUR_PATH_TO_DATASET/MH_01_easy.bag,但我这数据包放在catkin_ws目录下,所以直接能找到包。
第一个窗口运行 roslaunch vins_estimator euroc.launch 可能会报以下错误:
[feature_tracker-1] process has died [pid 3807, exit code -11, cmd /home/yaowei/catkin_ws/devel/lib/feature_tracker/feature_tracker __name:=feature_tracker __log:=/home/yaowei/.ros/log/f758c002-c23b-11ed-9f4b-e127444f3b2a/feature_tracker-1.log].
log file: /home/yaowei/.ros/log/f758c002-c23b-11ed-9f4b-e127444f3b2a/feature_tracker-1*.log
BRIEF_PATTERN_FILE/home/yaowei/catkin_ws/src/VINS-Mono-master/pose_graph/../support_files/brief_pattern.yml
[pose_graph-3] process has died [pid 3809, exit code -11, cmd /home/yaowei/catkin_ws/devel/lib/pose_graph/pose_graph __name:=pose_graph __log:=/home/yaowei/.ros/log/f758c002-c23b-11ed-9f4b-e127444f3b2a/pose_graph-3.log].
log file: /home/yaowei/.ros/log/f758c002-c23b-11ed-9f4b-e127444f3b2a/pose_graph-3*.log
解决方案:
将catkin_ws/src/VINS_Mono目录下的所有子文件夹的CMakeLists.txt中的find_package(OpenCV REQUIRED)全部改成find_package(OpenCV 4),然后再从新catkin_make,又会出现第七章第一步的错误,解决方法和之前一样。
解决后从新运行 roslaunch vins_estimator euroc.launch 即可。
4、运行结果
八、本文涉及的所有安装包
链接:https://pan.baidu.com/s/1vMkdSoFz-P5HdFuPaochLg
提取码:4fqs
–来自百度网盘超级会员V6的分享
内部包含VINS-Mono-master、Pangolin_v0.5、opencv-3.4.15、eigen-3.2.9、ceres-solver-1.14.0-master、EuRoC数据集-bag格式。
版权归原作者 黑灯瞎火正是学习之时 所有, 如有侵权,请联系我们删除。