知之盛者,莫大于成身,成身莫大于学。——《吕氏春秋》
不知不觉都快要九月份了,将近三个月没写博客了,赶紧来补一篇,记录分享一下配置VINS-Mono编译环境的过程。
VINS-Mono是单目视觉惯性系统的实时SLAM框架。 它使用基于优化的滑动窗口方式来提供高精度的视觉惯性测距。VINS-Mono主要用于自主无人机的状态估计和反馈控制,但它也能够为AR应用提供精确的定位。 此代码在Linux上运行,并与ROS完全集成。
完全按照Github上给出的环境:Windows 10 + Ubuntu 16.04双系统,ROS Kinetic, OpenCV 3.3.1, Eigen 3.3.3,Ceres-Solver
添加源:打开控制台Ctrl+Alt+T输入以下命令
sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list'
或者使用清华镜像:
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://ha.pool.sks-keyservers.net:80 --recv-key 0xB01FA116
确保系统软件处于最新版:
sudo apt-get update
安装全功能版ROS:
sudo apt-get install ros-kinetic-desktop-full
查看可用的包:
apt-cache search ros-kinetic
初始化ROS:
sudo rosdep init
rosdep update
初始化环境变量:
echo "source /opt/ros/kinetic/setup.bash" >> ~/.bashrc
source ~/.bashrc
安装常用插件:
sudo apt-get install python-rosinstall
测试ROS,启动ROS环境:
roscore
显示started core service [/rosout] 则安装成功。
去opencv官网opencv下载地址下载对应版本的opencv安装包
安装依赖项
sudo apt update
sudo apt install build-essential cmake git pkg-config libgtk-3-dev libavcodec-dev libavformat-dev libswscale-dev libv4l-dev libxvidcore-dev libx264-dev
sudo apt install libjpeg-dev libpng-dev libtiff-dev gfortran openexr libatlas-base-dev python3-dev python3-numpy libtbb2 libtbb-dev libdc1394-22-dev
解压opencv安装包,进入安装文件目录
tar -xzvf opencv-3.3.1.tar.gz
cd opencv-3.3.1/
cd ..
mkdir build
cd build
cmake ..
make -j8 # make -j8表示开8个线程来进行编译
sudo make install
安装完成
未安装Eigen的PC可以输入以下命令进行安装:
sudo apt-get install libeigen3-dev
可输入以下命令寻找安装位置:
sudo updatedb
locate eigen3
安装完成
官网英文安装教程
克隆安装包:
git clone https://ceres-solver.googlesource.com/ceres-solver
安装依赖项:
sudo apt-get install liblapack-dev libsuitesparse-dev libcxsparse3.1.4 libgflags-dev libgoogle-glog-dev libgtest-dev
以下安装参照安装教程进行
安装依赖项:
#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和CXSparse(可选)
# - 如果要将Ceres构建为* static *库(默认),您可以在主Ubuntu软件包#storage中使用SuiteSparse软件包:
sudo apt-get install libsuitesparse-dev
# - 但是,如果要将Ceres构建为* shared *库,则必须添加以下PPA:
sudo add-apt-repository ppa:bzindovic / suitesparse-bugfix-1319687
sudo apt-get update
sudo apt-get install libsuitesparse-dev
解压Cere安装包,进入安装目录下:
tar zxf ceres-solver-1.14.0.tar.gz
cd ceres-solver-1.14.0
mkdir build
cd build
cmake ..
make
sudo make install
ROS安装额外的ROS pacakge:
sudo apt-get install ros-kinetic-cv-bridge ros-kinetic-tf ros-kinetic-message-filters ros-kinetic-image-transport
下载测试数据集:https://projects.asl.ethz.ch/datasets/doku.php?id=kmavvisualinertialdatasets
在ROS上构建VINS-Mono,克隆存储库和catkin_make:
cd ~/catkin_ws/src
git clone https://github.com/HKUST-Aerial-Robotics/VINS-Mono.git
cd ../
catkin_make
打开三个终端,分别启动vins_estimator,rviz和播放包文件。以MH_01为例:
source ~/catkin_ws/devel/setup.bash
roslaunch vins_estimator euroc.launch
source ~/catkin_ws/devel/setup.bash
roslaunch vins_estimator vins_rviz.launch
注意测试数据的路径
source ~/catkin_ws/devel/setup.bash
rosbag play ~/catkin_ws/Dataset/MH_01_easy.bag
测试成功!
此时如果在CLion上对代码进行编译,不出意外的话会报下面的错误
CMake Error at /usr/local/share/catkin/cmake/catkinConfig.cmake:83 (find_package):
Could not find a package configuration file provided by "roscpp" with any
of the following names:
roscppConfig.cmake
roscpp-config.cmake
Add the installation prefix of "roscpp" to CMAKE_PREFIX_PATH or set
"roscpp_DIR" to a directory containing one of the above files. If "roscpp"
provides a separate development package or SDK, be sure it has been
installed.
报错信息中给出了两个解决方法,我一开始采用的是第一种,添加CMAKE_PREFIX_PATH环境变量,但是并不奏效;于是换第二种方式在camera_model的CMakeList.txt中添加”set(roscpp_DIR "/opt/ros/kinetic/share/roscpp/cmake")”即可,当然了,要写在报错位置前面才行。
补充,会有一些文件找不到,需要在CMake文件中添加:
set(roscpp_DIR "/opt/ros/kinetic/share/roscpp/cmake")
set(message_runtime_DIR "/opt/ros/kinetic/share/message_runtime/cmake")
set(roscpp_serialization_DIR "/opt/ros/kinetic/share/roscpp_serialization/cmake")
set(roscpp_traits_DIR "/opt/ros/kinetic/share/roscpp_traits/cmake")
set(rostime_DIR "/opt/ros/kinetic/share/rostime/cmake")
set(rosconsole_DIR "/opt/ros/kinetic/share/rosconsole/cmake")
set(rosgraph_msgs_DIR "/opt/ros/kinetic/share/rosgraph_msgs/cmake")
set(std_msgs_DIR "/opt/ros/kinetic/share/std_msgs/cmake")
set(xmlrpcpp_DIR "/opt/ros/kinetic/share/xmlrpcpp/cmake")
set(sensor_msgs_DIR "/opt/ros/kinetic/share/sensor_msgs/cmake")
set(geometry_msgs_DIR "/opt/ros/kinetic/share/geometry_msgs/cmake")
set(cv_bridge_DIR "/opt/ros/kinetic/share/cv_bridge/cmake")
set(camera_model_DIR "/home/dong/catkin_ws/devel/share/camera_model/cmake")
好了,就写到这里吧,希望下次写博客不会太久远!