NVIDIA Jetson Xavier NX部署VINS-fusion-GPU
一、环境配置(Ubuntu 18.04)
1、Cuda 10.2的安装
sudo apt-get updatesudo 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 Eigensudo apt-get remove libeigen3-dev cd ~/Downloads/wget -O eigen.zip /libeigen/eigen/-/archive/3.3.7/eigen-3.3.7.zip #check versionunzip eigen.zipmkdir eigen-build && cd eigen-buildcmake ../eigen-3.3.7/ && sudo make installpkg-config --modversion eigen3 # Check Eigen Version
3、Ceres solver
cd ~/Downloads/sudo apt-get install -y cmake libgoogle-glog-dev libatlas-base-dev libsuitesparse-devwget http://ceres-/ceres-solver-1.14.0.tar.gztar zxf ceres-solver-1.14.0.tar.gzmkdir ceres-binmkdir solver && cd ceres-bincmake ../ceres-solver-1.14.0 -DEXPORT_BUILD_DIR=ON -DCMAKE_INSTALL_PREFIX="../solver" #good for build without being root privileged and at wanted directorymake -j3 # 6 : number of coresmake installbin/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 opencvsudo apt-get purge libopencv* python-opencv sudo apt-get updatesudo apt-get install -y build-essential pkg-config## libeigen3-dev # recommend to build from sourcesudo 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-utilssudo 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.sosudo 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 /opencv/opencv/archive/3.4.1.zip # check versionunzip opencv.zipcd opencv-3.4.1/ && mkdir build && cd buildcmake -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 installcd ../../ && 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。首先,通过以下连接进入下载页面:
/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 COMPONENTSopencv_coreopencv_imgprocopencv_imgcodecsCONFIG)include(/usr/local/share/OpenCV/OpenCVConfig.cmake) #under catkin_python_setup()# Save and close CMakeLists# Build the packagecd .. && catkin_make
二、Vins-Fusion GPU编译安装
1、Vins-Fusion GPU
cd ~/catkin_ws/src && git clone /pjrambo/VINS-Fusion-gpu #GPUsudo apt-get install ros-melodic-tfsudo apt-get install ros-melodic-image-transportsudo apt-get install ros-melodic-rviz# Edit CMakeLists.txt for loop_fusion and vins_estimatorcd ~/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.bashcatkin_make
2、数据测试。
2.1公开数据集测试【以EuRoC(Stereo cameras + IMU)为例】
roslaunch vins vins_rviz.launchrosrun 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链接: /s/1UIoP1TgGLLWWpKYVrre9WA 密码: dbsbEuRoC链接: /s/1zvxyN1KlIk28_LvC36WU5Q 密码: f1rvshapenet链接: /s/1pdRk3FOxRe5YRBVGP0ACJw 密码: 4knlTUM链接: /s/1GFy8MZmH4TZGakzGWudyhQ 密码: ptga数据来源原文链接:/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 onuse_gpu_acc_flow: 0 for off, 1 for onIf your GPU resources is limitted or you want to use GPU for other computaion. You can setuse_gpu: 1use_gpu_acc_flow: 0If your other application do not require much GPU resources, I recommanded you to setuse_gpu: 1use_gpu_acc_flow: 1
IMU和相机外参标定可以通过VINS实时在线标定或者使用Kalibr工具包进行标定,相关资料比多了,不再赘述。
下期给各位铁子们汇报在阿木实验室P450上部署VINS+Prometheus+Ggo-Planner的工作。
文献参考
1、无人机自主导航(ARM架构的vins-fusion-GPU部署)
/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
/arjunskumar/vins-fusion-gpu-tx2-nano
3、调内外参数
/video/BV1WZ4y167me?p=11&vd_source=1682913523e03074db0225c9475c4c71
4、技术分享 | 带你具体部署VINS_FUSION_GPU版本
https://mp./s/FaE05W2vAvHCZc7R39M7Pw