主要记录下自己在Jetson Xavier NX上运行ROS、Cartographer、基于D435i的Yolov5+TensorRT的系统环境配置流程,经过了无数次在ARM上的安装,这次是最流畅的一次环境配置,很丝滑。感谢各位大佬们的帮助!!!
(采用的是官方的Xavier NX)
**
**
一、Jetson Xavier NX 用SD卡刷Jetpack4.5.1
二、开机配置
三、ROS环境安装
四、Cartographer环境安装
五、YoloV5+TensorRT7环境安装**
**
**
**
官方下载:https://developer.nvidia.com/embedded/downloads
下载完后按照官网刷镜像就ok
https://developer.nvidia.com/embedded/learn/get-started-jetson-xavier-nx-devkit#prepare
jetpack4系列默认ubuntu18.04
试了几次更换国内源,但是出现upgrade后重启进不去系统,Jetpack4.6没问题,因此本文省略换国内源。
1、直接更新:
sudo apt-get update
sudo apt-get upgrade
2、CUDA环境变量配置
sudo vim ~/.bashrc # 使用 Vim 编辑环境变量
在最后添加下面两行
export PATH=/usr/local/cuda/bin:$PATH
export LD_LIBRARY_PATH=/usr/local/cuda/lib64:$LD_LIBRARY_PATH
wq保存退出
source ~/.bashrc
安装pip3
sudo apt install python3-pip python3-dev
python3 -m pip install --upgrade pip #升级pip
安装 Jetson-stats 管理工具
sudo -H pip3 install jetson-stats
运行,输入命令,如果出现错误在安装一遍运行
sudo jtop
可通过按数字 1-6 来切换不同功能界面,按 q 离开。后续环境配置需要TensorRT7
3、ibus输入法安装
sudo apt-get install ibus-pinyin
安完重启,配置
sudo ibus-setup
1、添加ROS软件源
sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list'
2、添加公钥
sudo apt-key adv --keyserver 'hkp://keyserver.ubuntu.com:80' --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654
3、更新
sudo apt-get update
4、安装ros,推荐桌面完整版
sudo apt install ros-melodic-desktop-full
5、初始化 rosdep
sudo rosdep init
此时会报错误缺少rosdep包,用python安装(不要用python3安装):
sudo apt-get install python-rosdep
ERROR: cannot download default sources list from:
https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/sources.list.d/20-default.list
Website may be down.
直接新建文件并添加内容:
sudo su
sudo mkdir -p /etc/ros/rosdep/sources.list.d
cd /etc/ros/rosdep/sources.list.d
sudo gedit 20-default.list
添加如下内容:
# os-specific listings first rosdep update
yaml https://gitee.com/wybros/rosdistro/raw/master/rosdep/osx-homebrew.yaml osx
# generic
yaml https://gitee.com/wybros/rosdistro/raw/master/rosdep/base.yaml
yaml https://gitee.com/wybros/rosdistro/raw/master/rosdep/python.yaml
yaml https://gitee.com/wybros/rosdistro/raw/master/rosdep/ruby.yaml
gbpdistro https://gitee.com/wybros/rosdistro/raw/master/releases/fuerte.yaml fuerte
# newer distributions (Groovy, Hydro, ...) must not be listed anymore, they are being fetched from the rosdistro index.yaml instead
6、update之前进行文件修改
1.默认python2安装,需要到python2.7下更改文件路径
(1)/usr/lib/python2.7/dist-packages/rosdep2/rep3.py
将'https://raw.githubusercontent.com/ros/rosdistro/master/releases/targets.yaml'改为'https://gitee.com/wybros/rosdistro/raw/master/releases/targets.yaml'
(2)/usr/lib/python2.7/dist-packages/rosdistro/__init__.py
将'https://raw.githubusercontent.com/ros/rosdistro/master/index-v4.yaml'改为'https://gitee.com/wybros/rosdistro/raw/master/index-v4.yaml'
修改完之后
rosdep update
设置环境变量:
echo "source /opt/ros/melodic/setup.bash" >> ~/.bashrc
source ~/.bashrc
roscore即可。
安装rosinstall:
sudo apt-get install python-rosinstall python-rosinstall-generator python-wstool build-essential
参考链接:https://blog.csdn.net/waihekor/article/details/117221931
1、安装依赖库
sudo apt-get update
sudo apt-get install -y \
clang \
cmake \
g++ \
git \
google-mock \
libboost-all-dev \
libcairo2-dev \
libcurl4-openssl-dev \
libeigen3-dev \
libgflags-dev \
libgoogle-glog-dev \
liblua5.2-dev \
libsuitesparse-dev \
lsb-release \
ninja-build \
stow
2、初始化工作空间
cd catkin_google_ws
wstool init src
3、将链接中的功能包下载,把以下版本的功能包放到src目录里,版本要对应。
把解压的protobuf放到src同级目录下
4、ceres包下编译
cd ~/catkin_google_ws/src/ceres-solver-1.13.0
mkdir build
cd build
cmake .. -G Ninja -DCXX11=ON
ninja
CTEST_OUTPUT_ON_FAILURE=1 ninja test
sudo ninja install
5、安装protobuf
cd ~/catkin_google_ws/protobuf
mkdir build
cd build
cmake -G Ninja \
-DCMAKE_POSITION_INDEPENDENT_CODE=ON \
-DCMAKE_BUILD_TYPE=Release \
-Dprotobuf_BUILD_TESTS=OFF \
../cmake
ninja
sudo ninja install
装arm的:
cd ..
把autogen.sh文件的属性改成可执行文件
./autogen.sh
./configure --host=arm-linux --with-protoc=protoc
make
sudo make install
6、编译cartographer
cd ~/catkin_google_ws$
catkin_make_isolated --install --use-ninja
**
报错1:
**
解决方法:在下载回来的cartographer上有安装absl的脚本
sudo chmod +x ~/catkin_google_ws/src/cartographer-master/scripts/install_abseil.sh
cd ~/catkin_google_ws/src/cartographer-master/scripts
./install_abseil.sh
**
报错2:
**
/usr/local/bin/protoc: error while loading shared libraries: libprotoc.so.14: cannot open shared object file: No such file or directory
解决方法:
vim ~/.bashrc
底行添加:export LD_LIBRARY_PATH=/usr/local/lib
source ~/.bashrc
最后添加环境变量
echo "source ~/catkin_google_ws/install_isolated/setup.bash" >> ~/.bashrc
source ~/.bashrc
建图时发现工作空间路径和系统环境路径有顺序,以下是我的,可以正常建图。
至此Cartographer的环境完美安装,安装了无数次后,最快完成的一次,感谢各位大佬的帮助。
根据自己需求建图吧,我的实际建图效果:
1、YoloV5环境安装
参考链接:https://github.com/killnice/yolov5-D435i(Python版本)
**
报错1:
**
如果直接pip install -r requirements.txt安装 matplotlib会报错
解决办法:
pip3 install -i https://pypi.tuna.tsinghua.edu.cn/simple matplotlib==3.2.2
然后删掉txt中的matplotlib.本文采用默认自带的Python3.6.9安装环境
pip3 install -r requirements.txt
**
报错2:
**
ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.
launchpadlib 1.10.6 requires testresources, which is not installed.
解决办法:
python3.6 -m pip install launchpadlib
2、D435i环境安装
(1)目前还没有arm架构下的pyralsense2的PyPi包,因此在jetson使用pip安装的话,无法找到满足的版本,所以就源码编译安装:
下载zip包:https://github.com/IntelRealSense/librealsense/releases/
安装realsense2.50版本:
https://blog.csdn.net/weixin_62952541/article/details/130001682
安装realsense_ros报错:
把/usr/include/opencv 改成/usr/include/opencv4
之后ros下如果缺ddynamic_reconfigureConfig:
sudo apt-get install ros-melodic-ddynamic-reconfigure
3、TensorRT加速过程(C++版)
参考链接:https://github.com/RichardoMrMu/yolov5-deepsort-tensorrt
验证了下TensorRT8确实会出现版本问题,TensorRT7没问题。
**本文转载均给出链接,所有权利归属于原作者,如文章来源标示错误或侵犯了您的权利请联系邮箱[email protected]删除。