JETSON Xavier nx核心模组(ubuntu20.04)+RTSO-6002e载板
准备工作:
(1)安装jetpack5.1.1和Jetpack组件(cuda等)
(2)安装ros主页 | 鱼香ROS (fishros.org.cn)
(3)安装 ceres 1.14.0 Ubuntu20.04安装Ceres1.14.0
(4)安装opencv4.6.0
(5) 安装realsensehttps://blog.csdn.net/weixin_46151178/article/details/126349702?ops_request_misc=&request_id=3c7111dcdc884d26a06565100bf833a9&biz_id=&utm_medium=distribute.pc_search_result.none-task-blog-2~blog~koosearch~default-1-126349702-null-null.268^v1^control&utm_term=d435i&spm=1018.2226.3001.4450
6)安装VINS-Fusion-gpu
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
sudo apt-get purge libopencv* python-opencv sudo apt-get update sudo apt-get install -y build-essential pkg-config
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
发布 ·OpenCV/OpenCV (github.com)
版本 4.6.0 ·OpenCV/opencv_contrib (github.com)
编译 opencv 4.6.0,
mkdir opencv
解压下载的opencv和opencv_contrib-4.6.0到这里
sudo mkdir build && cd build cmake -D CMAKE_BUILD_TYPE=RELEASE \ -D CMAKE_INSTALL_PREFIX=/usr/local \ -D OPENCV_EXTRA_MODULES_PATH=../../opencv_contrib-4.6.0/modules \ -D WITH_CUDA=ON \ -D CUDA_ARCH_BIN=5.3 \ -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 -j6 sudo make install
OpenCV 在NX上的安装比较慢,差不多需要1个小时。OpenCV安装好以后,需要进一步编译CV-Bridge( cv_bridge是在ROS图像消息和OpenCV图像之间进行转换的一个功能包)。
因为 opencv 的数据和 ROS 的数据需要转化,因此需要通过 cv_bridge 这个桥接工具,接下来我们介绍怎么自己下载安装并配置一个自己的 cv_bridge 功能包。
首先,创建一个 ROS 的工作空间
mkdir -p ~/catkin_ws/src
cd ~/catkin_ws/src/
catkin_init_workspace
cd ..
catkin_make
echo "source ~/catkin_ws/devel/setup.bash" >> ~/.bashrc
source ~/.bashrc
然后,下载对应版本的源码,因为是 Ubuntu 20.04 因此下载 noetic 版本
1)CMakeLists.txt 文件
在 set(_opencv_version 4) 前面添加你的 opencv 安装路径,大概在第 20 行
https://github.com/ros-perception/vision_opencv/tree/noetic
下载完成后解压到 ~/catkin_ws/src 目录下,因为我们只需要 cv_bridge,所以只需保留 cv_bridge 文件夹,将其放在 ~/catkin_ws/src/,然后修改一下 cv_bridge 的配置文件。
set(OpenCV_DIR /home/nvidia/opencv/opencv-4.6.0/build/)
set(_opencv_version 4)
find_package(OpenCV 4 QUIET)
然后编译这个功能包
cd ~/catkin_ws/src
catkin_make
如果编译成功,则 cv_bridge功能包制作就完成了,这也说明 opencv 4.6.0 已经正确安装了,并且这个cv_bridge功能包可以正确连接上自己安装的 opencv 版本,最后我们将这个功能包的路径添加到 ~/.bashrc 文件夹中,使得我们在后面编译 vins-fusion-gpu 时可以调用这个 cv_bridge功能包,打开 ~/.bashrc文件夹,在最后加入如下命令
source ~/catkin_ws/devel/setup.bash
最后在终端 source 一下当前该路径
source ~/.bashrc
Command ‘rosrun‘ not found,rosrun找不到的问题
$ sudo apt install ros-noetic-rosbash
Jetson nx(Jetpack4.6版本)保姆级教程安装安装d435i-SDK流程踩坑,以及安装realsense与code_utils与imu_utils并标定imu内参附上测试demo_jetson jetpack 4.6 pyrealsense2_无证驾驶梁嗖嗖的博客-CSDN博客
cd ~/catkin_ws/src
git clone https://github.com/pjrambo/VINS-Fusion-gpu.git
修改 vins_estimator/CMakeLists.txt 文件
注释一行
#include(/home/dji/opencv/build/OpenCVConfig.cmake)
添加 cv_bridge_460 功能包的路径和 opencv-4.6.0 的路径
set(cv_bridge_460_DIR "/home/nvidia/catkin_ws/devel/share/cv_bridge/cmake")
set(OpenCV_DIR "/home/nvidia/opencv/opencv-4.6.0/build/")
保存并退出,最后进入 VINS-Fusion-gpu 文件夹
终端输入下面代码使得 VINS-Fusion-gpu 自动匹配 OpenCV4 版本(变量名发生变化)
sed -i 's/CV_FONT_HERSHEY_SIMPLEX/cv::FONT_HERSHEY_SIMPLEX/g' `grep CV_FONT_HERSHEY_SIMPLEX -rl ./`
sed -i 's/CV_LOAD_IMAGE_GRAYSCALE/cv::IMREAD_GRAYSCALE/g' `grep CV_LOAD_IMAGE_GRAYSCALE -rl ./`
sed -i 's/CV_BGR2GRAY/cv::COLOR_BGR2GRAY/g' `grep CV_BGR2GRAY -rl ./`
sed -i 's/CV_RGB2GRAY/cv::COLOR_RGB2GRAY/g' `grep CV_RGB2GRAY -rl ./`
sed -i 's/CV_GRAY2RGB/cv::COLOR_GRAY2RGB/g' `grep CV_GRAY2RGB -rl ./`
sed -i 's/CV_GRAY2BGR/cv::COLOR_GRAY2BGR/g' `grep CV_GRAY2BGR -rl ./`
sed -i 's/CV_CALIB_CB_ADAPTIVE_THRESH/cv::CALIB_CB_ADAPTIVE_THRESH/g' `grep CV_CALIB_CB_ADAPTIVE_THRESH -rl ./`
sed -i 's/CV_CALIB_CB_NORMALIZE_IMAGE/cv::CALIB_CB_NORMALIZE_IMAGE/g' `grep CV_CALIB_CB_NORMALIZE_IMAGE -rl ./`
sed -i 's/CV_CALIB_CB_FILTER_QUADS/cv::CALIB_CB_FILTER_QUADS/g' `grep CV_CALIB_CB_FILTER_QUADS -rl ./`
sed -i 's/CV_CALIB_CB_FAST_CHECK/cv::CALIB_CB_FAST_CHECK/g' `grep CV_CALIB_CB_FAST_CHECK -rl ./`
sed -i 's/CV_ADAPTIVE_THRESH_MEAN_C/cv::ADAPTIVE_THRESH_MEAN_C/g' `grep CV_ADAPTIVE_THRESH_MEAN_C -rl ./`
sed -i 's/CV_THRESH_BINARY/cv::THRESH_BINARY/g' `grep CV_THRESH_BINARY -rl ./`
sed -i 's/CV_SHAPE_CROSS/cv::MORPH_CROSS/g' `grep CV_SHAPE_CROSS -rl ./`
sed -i 's/CV_SHAPE_RECT/cv::MORPH_RECT/g' `grep CV_SHAPE_RECT -rl ./`
sed -i 's/CV_TERMCRIT_EPS/cv::TermCriteria::EPS/g' `grep CV_TERMCRIT_EPS -rl ./`
sed -i 's/CV_TERMCRIT_ITER/cv::TermCriteria::MAX_ITER/g' `grep CV_TERMCRIT_ITER -rl ./`
sed -i 's/CV_RETR_CCOMP/cv::RETR_CCOMP/g' `grep CV_RETR_CCOMP -rl ./`
sed -i 's/CV_CHAIN_APPROX_SIMPLE/cv::CHAIN_APPROX_SIMPLE/g' `grep CV_CHAIN_APPROX_SIMPLE -rl ./`
sed -i 's/CV_AA/cv::LINE_AA/g' `grep CV_AA -rl ./`
然后进入 catkin_ws/ 工作目录,进行编译
cd ~/catkin_ws/
catkin_make
编译成功后 VINS-Fusion-gpu 就可以成功运行啦!
例如出现“Could NOT find image_transport (missing: image_transport_DIR)”错误,那就需要在终端输入
sudo apt install ros-noetic-image-transport
ERROR: cannot launch node of type [rviz/rviz]: rviz
sudo apt-get install ros-noetic-rviz