VINS-Fusion:Ubuntu16.04 上opencv安装、ROS安装等各种坑

换源

由于Ubuntu自带的源速度极慢,因此换成国内的清华或者阿里等的源,百度一下换16.04的就好(别换成了14.04、18.04啥的就好)
换好源之后

sudo apt-get update;
sudo apt-get upgrade;

ceres安装

# CMake
sudo apt-get install cmake
# google-glog + gflags
sudo apt-get install libgoogle-glog-dev
# BLAS & LAPACK
sudo apt-get install libatlas-base-dev
# Eigen3
sudo apt-get install libeigen3-dev
# SuiteSparse and CXSparse (optional)
# - If you want to build Ceres as a *static* library (the default)
#   you can use the SuiteSparse package in the main Ubuntu package
#   repository:
sudo apt-get install libsuitesparse-dev

安装ceres
tar zxf ceres-solver-1.14.0.tar.gz
mkdir ceres-bin
cd ceres-bin
cmake ../ceres-solver-1.14.0
make -j3
make test
# Optionally install Ceres, it can also be exported using CMake which
# allows Ceres to be used without requiring installation, see the documentation
# for the EXPORT_BUILD_DIR option for more information.
make install

OpenCV安装(解决下载速度慢的问题)

安装OpenCV依赖

sudo apt-get install build-essential
 
sudo apt-get install cmake git libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev
sudo apt-get install python-dev python-numpy libtbb2 libtbb-dev libjpeg-dev libpng-dev libtiff-dev libjasper-dev libdc1394-22-dev

由于直接从国外OpenCV网站或者Github下载速度太慢,因此我将Github上的放到了Gitee码云上;其他的Github资源如果访问过慢也可以考虑通过码云下载。

直接下载码云上的OpenCV
git clone https://gitee.com/idle_on/opencv.git
cd opencv
git tag
上面显示了当前版本库中的所有tag,选择自己想要安装的版本,例如3.4.7
git checkout 3.4.7

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

ROS的安装

ROS官网给出的 packages.ros.org.在国内还是访问太慢(安装依赖问题好多都是这个qiang导致的。。。)

sudo sh -c '. /etc/lsb-release && echo "deb http://mirrors.tuna.tsinghua.edu.cn/ros/ubuntu/ $DISTRIB_CODENAME main" > /etc/apt/sources.list.d/ros-latest.list'
sudo apt-key adv --keyserver 'hkp://keyserver.ubuntu.com:80' --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654

安装,也不一定要安装ros-kinetic-desktop-full,但是学习ROS的话建议直接一下安装完毕吧,详细的可以翻阅ROS官网安装教程,可以参考这篇18.04上安装ROS-melodicd的方法

sudo apt-get update
sudo apt-get install ros-kinetic-desktop-full

ROS 初始化rosdep

sudo rosdep init
rosdep update

我在安装这一步的时候遇到了无法访问的问题最后通过修改Hosts临时解决GitHub的raw.githubusercontent.com无法链接的问题,详细参考

ERROR: cannot download default sources list from:
https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/sources.list.d/20-default.list
Website may be down.

ROS 环境配置

echo "source /opt/ros/kinetic/setup.bash" >> ~/.bashrc
source ~/.bashrc
如果只想改变当前shell的环境,则只运行下面的即可
source /opt/ros/kinetic/setup.bash

ROS的其他一些包的依赖

sudo apt install python-rosinstall python-rosinstall-generator python-wstool build-essential

VINS-Fusion安装

依赖装完之后

	mkdir ~/catkin_ws/src
    cd ~/catkin_ws/src
    #下载这一步如果太慢可以换gitee的
    #git clone https://gitee.com/idle_on/VINS-Fusion.git
    git clone https://github.com/HKUST-Aerial-Robotics/VINS-Fusion.git
    cd ../
    catkin_make
    source ~/catkin_ws/devel/setup.bash

在我安装时当我进行了catkin_make操作后,电脑由于配置太低卡死了,因此自己进入了build目录编译

cd build
make -j1 -l1

至此,安装完成了,运行的教程网上挺多的,就不赘述了,由于是安装踩坑完之后写的,安装过程可能有所遗漏,敬请谅解

你可能感兴趣的:(Linux杂项)