NVIDIA Jetson Xavier NX部署VINS-fusion-GPU
一、环境配置(Ubuntu 18.04)
1、Cuda 10.2的安装
sudo apt-get update
sudo apt-get install cuda-toolkit-10-2
安装好之后,在 .bashrc中配置环境变量。source之后,nvcc – version 即可查看cuda版本。
export PATH=/usr/local/cuda-10.2/bin${PATH:+:${PATH}}
export LD_LIBRARY_PATH=/usr/local/cuda-10.2/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
export CUDA_ROOT=/usr/local/cuda
2、Eigen(用ROS自带的也可以)
# Remove pre-built Eigen
sudo apt-get remove libeigen3-dev
cd ~/Downloads/
wget -O eigen.zip https://gitlab.com/libeigen/eigen/-/archive/3.3.7/eigen-3.3.7.zip #check version
unzip eigen.zip
mkdir eigen-build && cd eigen-build
cmake ../eigen-3.3.7/ && sudo make install
pkg-config --modversion eigen3 # Check Eigen Version
3、Ceres solver
cd ~/Downloads/
sudo apt-get install -y cmake libgoogle-glog-dev libatlas-base-dev libsuitesparse-dev
wget http://ceres-solver.org/ceres-solver-1.14.0.tar.gz
tar zxf ceres-solver-1.14.0.tar.gz
mkdir ceres-bin
mkdir solver && cd ceres-bin
cmake ../ceres-solver-1.14.0 -DEXPORT_BUILD_DIR=ON -DCMAKE_INSTALL_PREFIX="../solver"
#good for build without being root privileged and at wanted directory
make -j3 # 6 : number of cores
make install
bin/simple_bundle_adjuster ../ceres-solver-1.14.0/data/problem-16-22106-pre.txt # to check version
4、Opencv 安装
关于Opencv 的安装需要特别谨慎,不建议频繁删除以前的库,因为多个项目使用的版本可能不同,所以可以将常用的版本安装在/usr/local下,将其余版本安装在自己Download或者home下。
如果需要删除原来的版本,执行以下命令:
# remove prebuilt opencv
sudo apt-get purge libopencv* python-opencv
sudo apt-get update
sudo apt-get install -y build-essential pkg-config
## libeigen3-dev # recommend to build from source
sudo apt-get install -y cmake libavcodec-dev libavformat-dev libavutil-dev \
libglew-dev libgtk2.0-dev libgtk-3-dev libjpeg-dev libpng-dev libpostproc-dev \
libswscale-dev libtbb-dev libtiff5-dev libv4l-dev libxvidcore-dev \
libx264-dev qt5-default zlib1g-dev libgl1 libglvnd-dev pkg-config \
libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev mesa-utils
sudo apt-get install python2.7-dev python3-dev python-numpy python3-numpy
# To fix OpenGL related compilation problems
cd /usr/lib/aarch64-linux-gnu/
sudo ln -sf libGL.so.1.0.0 libGL.so
sudo vim /usr/local/cuda/include/cuda_gl_interop.h
# Comment (line #62~68) of cuda_gl_interop.h
//#if defined(__arm__) || defined(__aarch64__)
//#ifndef GL_VERSION
//#error Please include the appropriate gl headers before including cuda_gl_interop.h
//#endif
//#else
#include <GL/gl.h>
//#endif
安装新的版本(因为VINS-FUSION-GPU版本需要支持CUda的OpenCV,所以选择3.4.1版本)
Then once linking is done, go to Downloads to begin opencv installation
cd ~/Downloads/
wget -O opencv.zip https://github.com/opencv/opencv/archive/3.4.1.zip # check version
unzip opencv.zip
cd opencv-3.4.1/ && mkdir build && cd build
cmake -D CMAKE_BUILD_TYPE=RELEASE \
-D CMAKE_INSTALL_PREFIX=/usr/local \ #这里的/usr/local可以换成自己的安装路径,到时候在Cmakelist里设置自己设置的路径即可。
-D WITH_CUDA=ON \
-D CUDA_ARCH_BIN=7.2 \ #对于NX和AGX,选7.2,Nano,TX2选6.2
-D CUDA_ARCH_PTX="" \
-D ENABLE_FAST_MATH=ON \
-D CUDA_FAST_MATH=ON \
-D WITH_CUBLAS=ON \
-D WITH_LIBV4L=ON \
-D WITH_GSTREAMER=ON \
-D WITH_GSTREAMER_0_10=OFF \
-D WITH_QT=ON \
-D WITH_OPENGL=ON \
-D CUDA_NVCC_FLAGS="--expt-relaxed-constexpr" \
-D WITH_TBB=ON \
../
make # running in single core is good to resolve the compilation issues
sudo make install
cd ../../ && sudo rm -rf opencv-3.4.1 # optional (can save 10GB Disk Space)
pkg-config --modversion opencv # Check opencv Version
OpenCV 在NX上的安装比较慢,差不多需要1个小时。OpenCV安装好以后,需要进一步编译CV-Bridge( cv_bridge是在ROS图像消息和OpenCV图像之间进行转换的一个功能包)。
5、CV-Bridge的编译
CV-Bridge的安装需要下载对应的版本,由于NX 是基于Ubuntu 18.04的ARM系统,因此下载melodic版本的CV-Bridge。首先,通过以下连接进入下载页面:
https://github.com/ros-perception/vision_opencv
如图所示:
# 选择下载melodic版本到catkin_ws/src目录下,
gedit vision_opencv/cv_bridge/CMakeLists.txt
# Edit OpenCV PATHS in CMakeLists and include cmake file
# /usr/local/share/OpenCV 选择自己安装的OpenCV对应路径
find_package(OpenCV 3 REQUIRED PATHS /usr/local/share/OpenCV NO_DEFAULT_PATH
COMPONENTS
opencv_core
opencv_imgproc
opencv_imgcodecs
CONFIG
)
include(/usr/local/share/OpenCV/OpenCVConfig.cmake) #under catkin_python_setup()
# Save and close CMakeLists
# Build the package
cd .. && catkin_make
二、Vins-Fusion GPU编译安装
1、Vins-Fusion GPU
cd ~/catkin_ws/src && git clone https://github.com/pjrambo/VINS-Fusion-gpu #GPU
sudo apt-get install ros-melodic-tf
sudo apt-get install ros-melodic-image-transport
sudo apt-get install ros-melodic-rviz
# Edit CMakeLists.txt for loop_fusion and vins_estimator
cd ~/catkin_ws/src/VINS-Fusion-gpu/loop_fusion && gedit CMakeLists.txt
##For loop_fusion : line 19
#find_package(OpenCV)
# /usr/local/share/OpenCV/ OpenCVConfig.cmake 选择自己安装的OpenCV对应路径
include(/usr/local/share/OpenCV/OpenCVConfig.cmake)
cd ~/catkin_ws/src/VINS-Fusion-gpu/vins_estimator && gedit CMakeLists.txt
##For vins_estimator : line 20
#find_package(OpenCV REQUIRED)
# /usr/local/share/OpenCV/ OpenCVConfig.cmake 选择自己安装的OpenCV对应路径
include(/usr/local/share/OpenCV/OpenCVConfig.cmake)
cd ~/catkin_ws/
source devel/setup.bash
catkin_make
2、数据测试。
2.1公开数据集测试【以EuRoC(Stereo cameras + IMU)为例】
roslaunch vins vins_rviz.launch
rosrun vins vins_node ~/catkin_ws/src/VINS-Fusion/config/euroc/euroc_stereo_imu_config.yaml
(optional) rosrun loop_fusion loop_fusion_node ~/catkin_ws/src/VINS-Fusion/config/euroc/euroc_stereo_imu_config.yaml
rosbag play YOUR_DATASET_FOLDER/MH_01_easy.bag
数据可以通过一下链接下载到:
http://projects.asl.ethz.ch/datasets/doku.php?id=kmavvisualinertialdatasets
如果下载慢的话,也可以通过以下连接获取
KITTI
链接: https://pan.baidu.com/s/1UIoP1TgGLLWWpKYVrre9WA 密码: dbsb
EuRoC
链接: https://pan.baidu.com/s/1zvxyN1KlIk28_LvC36WU5Q 密码: f1rv
shapenet
链接: https://pan.baidu.com/s/1pdRk3FOxRe5YRBVGP0ACJw 密码: 4knl
TUM
链接: https://pan.baidu.com/s/1GFy8MZmH4TZGakzGWudyhQ 密码: ptga
数据来源原文链接:https://blog.csdn.net/weixin_43828675/article/details/117049952(感谢嚣张的叉烧包同志)
2.2 测试自己的设备(D435i+阿木P450)
在配置参数文件中加入以下参数,使得GPU起作用
In the config file, there are two parameters for gpu acceleration.
use_gpu: 0 for off, 1 for on
use_gpu_acc_flow: 0 for off, 1 for on
If your GPU resources is limitted or you want to use GPU for other computaion. You can set
use_gpu: 1
use_gpu_acc_flow: 0
If your other application do not require much GPU resources, I recommanded you to set
use_gpu: 1
use_gpu_acc_flow: 1
IMU和相机外参标定可以通过VINS实时在线标定或者使用Kalibr工具包进行标定,相关资料比多了,不再赘述。
下期给各位铁子们汇报在阿木实验室P450上部署VINS+Prometheus+Ggo-Planner的工作。
文献参考
1、无人机自主导航(ARM架构的vins-fusion-GPU部署)
https://blog.csdn.net/weixin_45600405/article/details/125249964?spm=1001.2101.3001.6650.3&utm_medium=distribute.pc_relevant.none-task-blog-2%7Edefault%7EESLANDING%7Edefault-3-125249964-blog-119830683.pc_relevant_landingrelevant&depth_1-utm_source=distribute.pc_relevant.none-task-blog-2%7Edefault%7EESLANDING%7Edefault-3-125249964-blog-119830683.pc_relevant_landingrelevant&utm_relevant_index=4
2、安装环境OpenCV
https://github.com/arjunskumar/vins-fusion-gpu-tx2-nano
3、调内外参数文章来源:https://www.toymoban.com/news/detail-812038.html
https://www.bilibili.com/video/BV1WZ4y167me?p=11&vd_source=1682913523e03074db0225c9475c4c71
4、技术分享 | 带你具体部署VINS_FUSION_GPU版本文章来源地址https://www.toymoban.com/news/detail-812038.html
https://mp.weixin.qq.com/s/FaE05W2vAvHCZc7R39M7Pw
到了这里,关于NVIDIA Jetson Xavier NX部署VINS-fusion-GPU的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!