现有平台资源基础:
在跑VINS-Mono时Jetson Xavier NX已经安装了:
python2.7.17;
OpenCV4.5.4;
Eigen3.3.4
它们三个的安装就不做介绍了
安装ceres2.0.0
下载ceres-solver-2.0.0:
http://ceres-solver.org/ceres-solver-2.0.0.tar.gz
下载完后,可以根据官网,安装依赖项和编译
安装依赖项和编译步骤:
# CMake
sudo apt-get install cmake
# google-glog + gflags
sudo apt-get install libgoogle-glog-dev libgflags-dev
# Use ATLAS for BLAS & LAPACK
sudo apt-get install libatlas-base-dev
# Eigen3
sudo apt-get install libeigen3-dev
# SuiteSparse (optional)
sudo apt-get install libsuitesparse-dev
编译、安装ceres-solver
tar zxf ceres-solver-2.1.0.tar.gz
mkdir ceres-bin
cd ceres-bin
cmake ../ceres-solver-2.1.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
安装Vins-Mono
在你自己的文件夹下新建文件夹catkin_ws
mkdir catkin_ws
在catkin_ws文件夹下新建文件夹devel
和src
cd catkin_ws
mkdir devel
mkdir src
项目工程文件夹建立到此完成
接下来,下载、编译VINS-Mono
cd src
git clone https://github.com/HKUST-Aerial-Robotics/VINS-Mono.git
cd ..
catkin_make
source devel/setup.bash
此时catkin_ws文件夹下会多一个build
文件夹
下载EuRoC数据集
注意:在
catkin_make
时会出现代码报错:
‘CV_GRAY2BGR’ was not declared in this scope
原因是自己安装的OpenCV版本过高
在相应的.cpp
文件里添加头文件
#include <opencv2/imgproc/types_c.h>
‘CV_AA’ was not declared in this scope
原因是自己安装的OpenCV版本过高
在相应的.cpp
文件里添加头文件
#include <opencv2/imgproc/imgproc_c.h>
‘CV_CALIB_CB_ADAPTIVE_THRESH’ was not declared in this scope
原因是自己安装的OpenCV版本过高
在相应的.cpp
文件里添加头文件
#include <opencv2/calib3d/calib3d_c.h>
‘CV_FONT_HERSHEY_SIMPLEX’ was not declared in this scope
原因是自己安装的OpenCV版本过高
在相应的.cpp
文件里添加头文件
#include <opencv2/imgproc/imgproc_c.h>
运行VINS-Mono:
在catkin_ws
文件夹下打开三个终端,运行VINS-Mono
第一个终端:
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
注意:在运行
roslaunch vins_estimator euroc.launch
时会出现进程死掉的现象:
[vins_estimator-2] process has died [pid 12283, exit code -11, cmd /home/xzt/catkin_ws/devel/lib/vins_estimator/vins_estimator __name:=vins_estimator __log:=/home/xzt/.ros/log/80f99180-e248-11ec-a970-84c5a661654d/vins_estimator-2.log].
log file: /home/xzt/.ros/log/80f99180-e248-11ec-a970-84c5a661654d/vins_estimator-2*.log
[feature_tracker-1] process has died [pid 12282, exit code -11, cmd /home/xzt/catkin_ws/devel/lib/feature_tracker/feature_tracker __name:=feature_tracker __log:=/home/xzt/.ros/log/80f99180-e248-11ec-a970-84c5a661654d/feature_tracker-1.log].
log file: /home/xzt/.ros/log/80f99180-e248-11ec-a970-84c5a661654d/feature_tracker-1*.log
[pose_graph-3] process has died [pid 12284, exit code -11, cmd /home/xzt/catkin_ws/devel/lib/pose_graph/pose_graph __name:=pose_graph __log:=/home/xzt/.ros/log/80f99180-e248-11ec-a970-84c5a661654d/pose_graph-3.log].
log file: /home/xzt/.ros/log/80f99180-e248-11ec-a970-84c5a661654d/pose_graph-3*.log
这是由于ROS里的cv_bridge
与自己的OpenCV版本不一致,导致的。
解决办法:改cv_bridge
里的配置文件:
cd /opt/ros/kinetic/share/cv_bridge/cmake/
sudo gedit cv_bridgeConfig.cmake
下面是文件里改完的:
#if(NOT "include;/usr/include;/usr/include/opencv " STREQUAL " ")
#set(cv_bridge_INCLUDE_DIRS "")
#set(_include_dirs "include;/usr/include;/usr/include/opencv4")
if(NOT "include;/usr/local/include;/usr/local/include/opencv4 " STREQUAL " ")
set(cv_bridge_INCLUDE_DIRS "")
set(_include_dirs "include;/usr/local/include;/usr/local/include/opencv4")
#set(libraries "cv_bridge;/usr/lib/aarch64-linux-gnu/libopencv_core.so.3.2.0;/usr/lib/aarch64-linux-gnu/#libopencv_imgproc.so.3.2.0;/usr/lib/aarch64-linux-gnu/libopencv_imgcodecs.so.3.2.0")
set(libraries "cv_bridge;/usr/local/lib/libopencv_core.so.4.5.4;/usr/local/lib/libopencv_imgproc.so.4.5.4;/usr/local/lib/libopencv_imgcodecs.so.4.5.4")
就改了这两个地方,再回到catkin_ws
文件夹下,运行VINS-Mono就成功了